Skip to content

Commit

Permalink
Uplift VS Code to 1.83.1. Fixes eclipse-theia#12679
Browse files Browse the repository at this point in the history
Contributed on behalf of STMicroelectronics

Signed-off-by: Thomas Mäder <t.s.maeder@gmail.com>
  • Loading branch information
tsmaeder committed Feb 5, 2024
1 parent 3e7f6ee commit 337352b
Show file tree
Hide file tree
Showing 59 changed files with 457 additions and 413 deletions.
2 changes: 1 addition & 1 deletion examples/api-tests/src/monaco-api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('Monaco API', async function () {
});

it('Supports setting contexts using the command registry', async () => {
const setContext = 'setContext';
const setContext = '_setContext';
const key = 'monaco-api-test-context';
const firstValue = 'first setting';
const secondValue = 'second setting';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { enableJSDOM } from '@theia/core/lib/browser/test/jsdom';
import * as chai from 'chai';
import { ResourceTextEdit } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/bulkEditService';
import { URI as Uri } from 'vscode-uri';
import { URI as Uri } from '@theia/core/shared/vscode-uri';

let disableJSDOM = enableJSDOM();

Expand Down
1 change: 0 additions & 1 deletion packages/console/src/browser/console-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ export class ConsoleWidget extends BaseWidget implements StatefulWidget {
input.getControl().createContextKey('consoleInputFocus', true);
const contentContext = this.contextKeyService.createScoped(this.content.node);
contentContext.setContext('consoleContentFocus', true);
this.toDispose.push(contentContext);
}

protected createInput(node: HTMLElement): Promise<MonacoEditor> {
Expand Down
3 changes: 1 addition & 2 deletions packages/core/src/browser/context-key-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// *****************************************************************************

import { injectable } from 'inversify';
import { Disposable } from '../common';
import { Emitter, Event } from '../common/event';

export type ContextKeyValue = null | undefined | boolean | number | string
Expand Down Expand Up @@ -43,7 +42,7 @@ export interface ContextKeyChangeEvent {

export const ContextKeyService = Symbol('ContextKeyService');

export interface ContextMatcher extends Disposable {
export interface ContextMatcher {
/**
* Whether the expression is satisfied. If `context` provided, the service will attempt to retrieve a context object associated with that element.
*/
Expand Down
4 changes: 0 additions & 4 deletions packages/core/src/browser/context-menu-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export const Coordinate = Symbol('Coordinate');

export type Anchor = MouseEvent | Coordinate;

export function toAnchor(anchor: HTMLElement | Coordinate): Anchor {
return anchor instanceof HTMLElement ? { x: anchor.offsetLeft, y: anchor.offsetTop } : anchor;
}

export function coordinateFromAnchor(anchor: Anchor): Coordinate {
const { x, y } = anchor instanceof MouseEvent ? { x: anchor.clientX, y: anchor.clientY } : anchor;
return { x, y };
Expand Down
11 changes: 1 addition & 10 deletions packages/core/src/browser/icon-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*--------------------------------------------------------------------------------------------*/
// code copied and modified from https://github.com/Microsoft/vscode/blob/main/src/vs/platform/theme/common/iconRegistry.ts

import { ThemeIcon } from '../common/theme';
import { URI } from 'vscode-uri';

export interface IconDefinition {
Expand Down Expand Up @@ -48,16 +49,6 @@ export interface IconFontSource {
readonly location: URI;
readonly format: string;
}

export interface ThemeIcon {
readonly id: string;
readonly color?: ThemeColor;
}

export interface ThemeColor {
id: string;
}

export const IconRegistry = Symbol('IconRegistry');
export interface IconRegistry {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { codicon } from '../widgets';

// #region Copied from Copied from https://github.com/microsoft/vscode/blob/7d9b1c37f8e5ae3772782ba3b09d827eb3fdd833/src/vs/base/browser/formattedTextRenderer.ts
export interface ContentActionHandler {
callback: (content: string, event?: MouseEvent) => void;
callback: (content: string, event?: MouseEvent | KeyboardEvent) => void;
readonly disposables: DisposableGroup;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ import { UriComponents } from '../uri';
import { escapeIcons } from './icon-utilities';
import { isObject, isString } from '../types';

export interface MarkdownStringTrustedOptions {
readonly enabledCommands: readonly string[];
}

export interface MarkdownString {
readonly value: string;
readonly isTrusted?: boolean;
readonly isTrusted?: boolean | MarkdownStringTrustedOptions;
readonly supportThemeIcons?: boolean;
readonly supportHtml?: boolean;
readonly baseUri?: UriComponents;
Expand All @@ -45,9 +49,8 @@ export namespace MarkdownString {
// Copied from https://github.com/microsoft/vscode/blob/7d9b1c37f8e5ae3772782ba3b09d827eb3fdd833/src/vs/base/common/htmlContent.ts

export class MarkdownStringImpl implements MarkdownString {

public value: string;
public isTrusted?: boolean;
public isTrusted?: boolean | MarkdownStringTrustedOptions;
public supportThemeIcons?: boolean;
public supportHtml?: boolean;
public baseUri?: UriComponents;
Expand Down
42 changes: 10 additions & 32 deletions packages/core/src/common/quick-pick-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import URI from './uri';
import * as fuzzy from 'fuzzy';
import { Event } from './event';
import { KeySequence } from './keys';
Expand Down Expand Up @@ -54,11 +53,11 @@ export interface QuickPickItem {
description?: string;
detail?: string;
keySequence?: KeySequence;
iconPath?: URI | Uri | { light?: URI | Uri; dark: URI | Uri } | { id: string };
iconPath?: { light?: Uri; dark: Uri };
iconClasses?: string[];
alwaysShow?: boolean;
highlights?: QuickPickItemHighlights;
buttons?: readonly QuickInputButton[];
buttons?: QuickInputButton[];
execute?: () => void;
}

Expand Down Expand Up @@ -95,7 +94,7 @@ export interface QuickPickValue<V> extends QuickPickItem {
}

export interface QuickInputButton {
iconPath?: URI | Uri | { light?: URI | Uri; dark: URI | Uri } | { id: string };
iconPath?: { light?: Uri; dark: Uri };
iconClass?: string;
tooltip?: string;
/**
Expand All @@ -104,32 +103,6 @@ export interface QuickInputButton {
alwaysVisible?: boolean;
}

export interface NormalizedQuickInputButton extends QuickInputButton {
iconPath?: { light?: Uri, dark: Uri };
}

export namespace QuickInputButton {
export function normalize(button: undefined): undefined;
export function normalize(button: QuickInputButton): NormalizedQuickInputButton;
export function normalize(button?: QuickInputButton): NormalizedQuickInputButton | undefined {
if (!button) {
return button;
}
let iconPath: NormalizedQuickInputButton['iconPath'] = undefined;
if (button.iconPath instanceof URI) {
iconPath = { dark: button.iconPath['codeUri'] };
} else if (button.iconPath && 'dark' in button.iconPath) {
const dark = Uri.isUri(button.iconPath.dark) ? button.iconPath.dark : button.iconPath.dark['codeUri'];
const light = Uri.isUri(button.iconPath.light) ? button.iconPath.light : button.iconPath.light?.['codeUri'];
iconPath = { dark, light };
}
return {
...button,
iconPath,
};
}
}

export interface QuickInputButtonHandle extends QuickInputButton {
handle: number; // index of where the button is in buttons array if QuickInputButton or -1 if QuickInputButtons.Back
}
Expand Down Expand Up @@ -281,8 +254,13 @@ export interface QuickInputService {
open(filter: string): void;
createInputBox(): InputBox;
input(options?: InputOptions, token?: CancellationToken): Promise<string | undefined>;
pick<T extends QuickPickItem, O extends PickOptions<T>>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: O, token?: CancellationToken):
Promise<(O extends { canPickMany: true } ? T[] : T) | undefined>;
pick<T extends QuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[],
options?: PickOptions<T> & { canPickMany: true }, token?: CancellationToken): Promise<T[] | undefined>;
pick<T extends QuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[],
options?: PickOptions<T> & { canPickMany: false }, token?: CancellationToken): Promise<T | undefined>;
pick<T extends QuickPickItem>(picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[],
options?: Omit<PickOptions<T>, 'canPickMany'>, token?: CancellationToken): Promise<T | undefined>;

showQuickPick<T extends QuickPickItem>(items: Array<T | QuickPickSeparator>, options?: QuickPickOptions<T>): Promise<T | undefined>;
hide(): void;
/**
Expand Down
32 changes: 32 additions & 0 deletions packages/core/src/common/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { URI } from 'vscode-uri';

export type ThemeType = 'light' | 'dark' | 'hc' | 'hcLight';

export interface Theme {
Expand All @@ -34,3 +36,33 @@ export interface ThemeChangeEvent {
readonly newTheme: Theme;
readonly oldTheme?: Theme;
}

export interface ThemeColor {
id: string;
}

export interface ThemeIcon {
readonly id: string;
readonly color?: ThemeColor;
}

export interface IconDefinition {
font?: IconFontContribution; // undefined for the default font (codicon)
fontCharacter: string;
}

export interface IconFontContribution {
readonly id: string;
readonly definition: IconFontDefinition;
}

export interface IconFontDefinition {
readonly weight?: string;
readonly style?: string;
readonly src: IconFontSource[];
}

export interface IconFontSource {
readonly location: URI;
readonly format: string;
}
6 changes: 4 additions & 2 deletions packages/core/src/common/uri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ import { Path } from './path';

export class URI {

public static fromComponents(components: UriComponents): URI {
return new URI(Uri.revive(components));
public static fromComponents(components: UriComponents): URI;
public static fromComponents(components: undefined): undefined;
public static fromComponents(components: UriComponents | undefined): URI | undefined {
return components ? new URI(Uri.revive(components)) : undefined;
}

public static fromFilePath(path: string): URI {
Expand Down
2 changes: 1 addition & 1 deletion packages/debug/src/browser/debug-session-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export class DebugSessionManager {
}

isCurrentEditorFrame(uri: URI | string | monaco.Uri): boolean {
return this.currentFrame?.source?.uri.toString() === (uri instanceof URI ? uri : new URI(uri)).toString();
return this.currentFrame?.source?.uri.toString() === (uri instanceof URI ? uri : new URI(uri.toString())).toString();
}

protected async saveAll(): Promise<boolean> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ export class InstructionRenderer extends Disposable implements ITableRenderer<Di

while (lineNumber && lineNumber >= 1 && lineNumber <= textModel.getLineCount()) {
const lineContent = textModel.getLineContent(lineNumber);
sourceSB.appendASCIIString(` ${lineNumber}: `);
sourceSB.appendASCIIString(lineContent + '\n');
sourceSB.appendString(` ${lineNumber}: `);
sourceSB.appendString(lineContent + '\n');

if (instruction.endLine && lineNumber < instruction.endLine) {
lineNumber++;
Expand All @@ -129,27 +129,27 @@ export class InstructionRenderer extends Disposable implements ITableRenderer<Di
let spacesToAppend = 10;

if (instruction.address !== '-1') {
sb.appendASCIIString(instruction.address);
sb.appendString(instruction.address);
if (instruction.address.length < InstructionRenderer.INSTRUCTION_ADDR_MIN_LENGTH) {
spacesToAppend = InstructionRenderer.INSTRUCTION_ADDR_MIN_LENGTH - instruction.address.length;
}
for (let i = 0; i < spacesToAppend; i++) {
sb.appendASCIIString(' ');
sb.appendString(' ');
}
}

if (instruction.instructionBytes) {
sb.appendASCIIString(instruction.instructionBytes);
sb.appendString(instruction.instructionBytes);
spacesToAppend = 10;
if (instruction.instructionBytes.length < InstructionRenderer.INSTRUCTION_BYTES_MIN_LENGTH) {
spacesToAppend = InstructionRenderer.INSTRUCTION_BYTES_MIN_LENGTH - instruction.instructionBytes.length;
}
for (let i = 0; i < spacesToAppend; i++) {
sb.appendASCIIString(' ');
sb.appendString(' ');
}
}

sb.appendASCIIString(instruction.instruction);
sb.appendString(instruction.instruction);
column.instruction.innerText = sb.build();

this.rerenderBackground(column.instruction, column.sourcecode, element);
Expand Down Expand Up @@ -191,7 +191,7 @@ export class InstructionRenderer extends Disposable implements ITableRenderer<Di
mode: 'activate',
widgetOptions: { area: 'main' }
};
open(this.openerService, new TheiaURI(sourceURI), openerOptions);
open(this.openerService, new TheiaURI(sourceURI.toString()), openerOptions);
}
}

Expand Down
7 changes: 2 additions & 5 deletions packages/debug/src/browser/editor/debug-editor-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { IEditorHoverOptions } from '@theia/monaco-editor-core/esm/vs/editor/com
import URI from '@theia/core/lib/common/uri';
import { Disposable, DisposableCollection, MenuPath, isOSX } from '@theia/core';
import { ContextMenuRenderer } from '@theia/core/lib/browser';
import { MonacoConfigurationService } from '@theia/monaco/lib/browser/monaco-frontend-module';
import { BreakpointManager, SourceBreakpointsChangeEvent } from '../breakpoint/breakpoint-manager';
import { DebugSourceBreakpoint } from '../model/debug-source-breakpoint';
import { DebugSessionManager } from '../debug-session-manager';
Expand All @@ -35,6 +34,7 @@ import { DebugBreakpointWidget } from './debug-breakpoint-widget';
import { DebugExceptionWidget } from './debug-exception-widget';
import { DebugProtocol } from '@vscode/debugprotocol';
import { DebugInlineValueDecorator, INLINE_VALUE_DECORATION_KEY } from './debug-inline-value-decorator';
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';

export const DebugEditorModelFactory = Symbol('DebugEditorModelFactory');
export type DebugEditorModelFactory = (editor: DebugEditor) => DebugEditorModel;
Expand Down Expand Up @@ -94,9 +94,6 @@ export class DebugEditorModel implements Disposable {
@inject(DebugInlineValueDecorator)
readonly inlineValueDecorator: DebugInlineValueDecorator;

@inject(MonacoConfigurationService)
readonly configurationService: IConfigurationService;

@inject(DebugSessionManager)
protected readonly sessionManager: DebugSessionManager;

Expand Down Expand Up @@ -156,7 +153,7 @@ export class DebugEditorModel implements Disposable {
resource: model.uri,
overrideIdentifier: model.getLanguageId(),
};
const { enabled, delay, sticky } = this.configurationService.getValue<IEditorHoverOptions>('editor.hover', overrides);
const { enabled, delay, sticky } = StandaloneServices.get(IConfigurationService).getValue<IEditorHoverOptions>('editor.hover', overrides);
codeEditor.updateOptions({
hover: {
enabled,
Expand Down
1 change: 0 additions & 1 deletion packages/editor/src/browser/diff-navigator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import { TextEditor } from './editor';

export interface DiffNavigator {
canNavigate(): boolean;
hasNext(): boolean;
hasPrevious(): boolean;
next(): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ export class EditorLineNumberContribution implements FrontendApplicationContribu
menuPath: EDITOR_LINENUMBER_CONTEXT_MENU,
anchor: event.event,
args,
contextKeyService,
onHide: () => contextKeyService.dispose()
contextKeyService
});
});
}
Expand Down
10 changes: 4 additions & 6 deletions packages/filesystem/src/browser/file-upload-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ import { nls } from '@theia/core/lib/common/nls';

export const HTTP_UPLOAD_URL: string = new Endpoint({ path: HTTP_FILE_UPLOAD_PATH }).getRestUrl().toString(true);

export interface CustomDataTransfer {
values(): Iterable<CustomDataTransferItem>
}
export type CustomDataTransfer = Iterable<readonly [string, CustomDataTransferItem]>;

export interface CustomDataTransferItem {
readonly id: string;
asFile(): {
readonly id: string;
readonly name: string;
data(): Promise<Uint8Array>;
} | undefined
Expand Down Expand Up @@ -420,10 +418,10 @@ export class FileUploadService {
}

protected async indexCustomDataTransfer(targetUri: URI, dataTransfer: CustomDataTransfer, context: FileUploadService.Context): Promise<void> {
for (const item of dataTransfer.values()) {
for (const [_, item] of dataTransfer) {
const fileInfo = item.asFile();
if (fileInfo) {
await this.indexFile(targetUri, new File([await fileInfo.data()], item.id), context);
await this.indexFile(targetUri, new File([await fileInfo.data()], fileInfo.id), context);
}
}
}
Expand Down
Loading

0 comments on commit 337352b

Please sign in to comment.