Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)

* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973

* disable strict null check
This commit is contained in:
Anthony Dresser
2019-07-15 22:35:46 -07:00
committed by GitHub
parent f720ec642f
commit 0b7e7ddbf9
2406 changed files with 59140 additions and 35464 deletions

View File

@@ -27,7 +27,7 @@ import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiati
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { contrastBorder, editorWidgetBackground, widgetShadow } from 'vs/platform/theme/common/colorRegistry';
import { contrastBorder, editorWidgetBackground, widgetShadow, editorWidgetForeground } from 'vs/platform/theme/common/colorRegistry';
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
import { AccessibilityHelpNLS } from 'vs/editor/common/standaloneStrings';
@@ -371,6 +371,11 @@ registerThemingParticipant((theme, collector) => {
if (widgetBackground) {
collector.addRule(`.monaco-editor .accessibilityHelpWidget { background-color: ${widgetBackground}; }`);
}
const widgetForeground = theme.getColor(editorWidgetForeground);
if (widgetForeground) {
collector.addRule(`.monaco-editor .accessibilityHelpWidget { color: ${widgetForeground}; }`);
}
const widgetShadowColor = theme.getColor(widgetShadow);
if (widgetShadowColor) {

View File

@@ -13,12 +13,12 @@
position: absolute;
resize: none;
overflow: hidden;
background: url('keyboard.svg') center center no-repeat;
background: url('keyboard-light.svg') center center no-repeat;
border: 4px solid #F6F6F6;
border-radius: 4px;
}
.monaco-editor.vs-dark .iPadShowKeyboard {
background: url('keyboard-inverse.svg') center center no-repeat;
background: url('keyboard-dark.svg') center center no-repeat;
border: 4px solid #252526;
}

View File

@@ -6,24 +6,23 @@
import 'vs/css!./iPadShowKeyboard';
import * as browser from 'vs/base/browser/browser';
import * as dom from 'vs/base/browser/dom';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { Disposable } from 'vs/base/common/lifecycle';
import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser';
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { IEditorContribution } from 'vs/editor/common/editorCommon';
export class IPadShowKeyboard implements IEditorContribution {
export class IPadShowKeyboard extends Disposable implements IEditorContribution {
private static readonly ID = 'editor.contrib.iPadShowKeyboard';
private readonly editor: ICodeEditor;
private widget: ShowKeyboardWidget | null;
private toDispose: IDisposable[];
constructor(editor: ICodeEditor) {
super();
this.editor = editor;
this.toDispose = [];
if (browser.isIPad) {
this.toDispose.push(editor.onDidChangeConfiguration(() => this.update()));
this._register(editor.onDidChangeConfiguration(() => this.update()));
this.update();
}
}
@@ -48,7 +47,7 @@ export class IPadShowKeyboard implements IEditorContribution {
}
public dispose(): void {
this.toDispose = dispose(this.toDispose);
super.dispose();
if (this.widget) {
this.widget.dispose();
this.widget = null;
@@ -56,25 +55,24 @@ export class IPadShowKeyboard implements IEditorContribution {
}
}
class ShowKeyboardWidget implements IOverlayWidget {
class ShowKeyboardWidget extends Disposable implements IOverlayWidget {
private static readonly ID = 'editor.contrib.ShowKeyboardWidget';
private readonly editor: ICodeEditor;
private readonly _domNode: HTMLElement;
private _toDispose: IDisposable[];
constructor(editor: ICodeEditor) {
super();
this.editor = editor;
this._domNode = document.createElement('textarea');
this._domNode.className = 'iPadShowKeyboard';
this._toDispose = [];
this._toDispose.push(dom.addDisposableListener(this._domNode, 'touchstart', (e) => {
this._register(dom.addDisposableListener(this._domNode, 'touchstart', (e) => {
this.editor.focus();
}));
this._toDispose.push(dom.addDisposableListener(this._domNode, 'focus', (e) => {
this._register(dom.addDisposableListener(this._domNode, 'focus', (e) => {
this.editor.focus();
}));
@@ -83,7 +81,7 @@ class ShowKeyboardWidget implements IOverlayWidget {
public dispose(): void {
this.editor.removeOverlayWidget(this);
this._toDispose = dispose(this._toDispose);
super.dispose();
}
// ----- IOverlayWidget API

View File

@@ -0,0 +1,10 @@
<svg width="53" height="36" viewBox="0 0 53 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M48.0364 4.01042H4.00779L4.00779 32.0286H48.0364V4.01042ZM4.00779 0.0078125C1.79721 0.0078125 0.00518799 1.79984 0.00518799 4.01042V32.0286C0.00518799 34.2392 1.79721 36.0312 4.00779 36.0312H48.0364C50.247 36.0312 52.039 34.2392 52.039 32.0286V4.01042C52.039 1.79984 50.247 0.0078125 48.0364 0.0078125H4.00779ZM8.01042 8.01302H12.013V12.0156H8.01042V8.01302ZM20.0182 8.01302H16.0156V12.0156H20.0182V8.01302ZM24.0208 8.01302H28.0234V12.0156H24.0208V8.01302ZM36.0286 8.01302H32.026V12.0156H36.0286V8.01302ZM40.0312 8.01302H44.0339V12.0156H40.0312V8.01302ZM16.0156 16.0182H8.01042V20.0208H16.0156V16.0182ZM20.0182 16.0182H24.0208V20.0208H20.0182V16.0182ZM32.026 16.0182H28.0234V20.0208H32.026V16.0182ZM44.0339 16.0182V20.0208H36.0286V16.0182H44.0339ZM12.013 24.0234H8.01042V28.026H12.013V24.0234ZM16.0156 24.0234H36.0286V28.026H16.0156V24.0234ZM44.0339 24.0234H40.0312V28.026H44.0339V24.0234Z" fill="#C5C5C5"/>
</g>
<defs>
<clipPath id="clip0">
<rect width="53" height="36" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="58" height="36"><path fill="#2B282E" d="M54 32v-28h-50v28h50zm-16-2h-18v-6h18v6zm6 0h-4v-6h4v6zm8 0h-6v-6h6v6zm-4-24h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm-6-12h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm-6-12h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm-6-12h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm-6-12h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm-6-12h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm0 12h-4v-6h4v6zm-6-24h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm-6-12h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h6v6h-6v-6z"/><path fill="#C5C5C5" d="M55.336 0h-53.285c-1.344 0-2.051.656-2.051 2v32c0 1.344.707 1.965 2.051 1.965l53.949.035c1.344 0 2-.656 2-2v-32c0-1.344-1.32-2-2.664-2zm-1.336 32h-50v-28h50v28z"/><rect x="6" y="12" fill="#C5C5C5" width="4" height="4"/><rect x="12" y="12" fill="#C5C5C5" width="4" height="4"/><rect x="18" y="12" fill="#C5C5C5" width="4" height="4"/><rect x="24" y="12" fill="#C5C5C5" width="4" height="4"/><rect x="30" y="12" fill="#C5C5C5" width="4" height="4"/><rect x="36" y="12" fill="#C5C5C5" width="4" height="4"/><rect x="42" y="12" fill="#C5C5C5" width="4" height="4"/><rect x="48" y="12" fill="#C5C5C5" width="4" height="4"/><rect x="6" y="6" fill="#C5C5C5" width="4" height="4"/><rect x="12" y="6" fill="#C5C5C5" width="4" height="4"/><rect x="18" y="6" fill="#C5C5C5" width="4" height="4"/><rect x="24" y="6" fill="#C5C5C5" width="4" height="4"/><rect x="30" y="6" fill="#C5C5C5" width="4" height="4"/><rect x="36" y="6" fill="#C5C5C5" width="4" height="4"/><rect x="42" y="6" fill="#C5C5C5" width="4" height="4"/><rect x="48" y="6" fill="#C5C5C5" width="4" height="4"/><rect x="6" y="18" fill="#C5C5C5" width="4" height="4"/><rect x="12" y="18" fill="#C5C5C5" width="4" height="4"/><rect x="18" y="18" fill="#C5C5C5" width="4" height="4"/><rect x="24" y="18" fill="#C5C5C5" width="4" height="4"/><rect x="30" y="18" fill="#C5C5C5" width="4" height="4"/><rect x="36" y="18" fill="#C5C5C5" width="4" height="4"/><rect x="42" y="18" fill="#C5C5C5" width="4" height="4"/><rect x="48" y="18" fill="#C5C5C5" width="4" height="4"/><rect x="6" y="24" fill="#C5C5C5" width="6" height="6"/><rect x="46" y="24" fill="#C5C5C5" width="6" height="6"/><rect x="20" y="24" fill="#C5C5C5" width="18" height="6"/><rect x="14" y="24" fill="#C5C5C5" width="4" height="6"/><rect x="40" y="24" fill="#C5C5C5" width="4" height="6"/></svg>

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -0,0 +1,10 @@
<svg width="53" height="36" viewBox="0 0 53 36" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M48.0364 4.01042H4.00779L4.00779 32.0286H48.0364V4.01042ZM4.00779 0.0078125C1.79721 0.0078125 0.00518799 1.79984 0.00518799 4.01042V32.0286C0.00518799 34.2392 1.79721 36.0312 4.00779 36.0312H48.0364C50.247 36.0312 52.039 34.2392 52.039 32.0286V4.01042C52.039 1.79984 50.247 0.0078125 48.0364 0.0078125H4.00779ZM8.01042 8.01302H12.013V12.0156H8.01042V8.01302ZM20.0182 8.01302H16.0156V12.0156H20.0182V8.01302ZM24.0208 8.01302H28.0234V12.0156H24.0208V8.01302ZM36.0286 8.01302H32.026V12.0156H36.0286V8.01302ZM40.0312 8.01302H44.0339V12.0156H40.0312V8.01302ZM16.0156 16.0182H8.01042V20.0208H16.0156V16.0182ZM20.0182 16.0182H24.0208V20.0208H20.0182V16.0182ZM32.026 16.0182H28.0234V20.0208H32.026V16.0182ZM44.0339 16.0182V20.0208H36.0286V16.0182H44.0339ZM12.013 24.0234H8.01042V28.026H12.013V24.0234ZM16.0156 24.0234H36.0286V28.026H16.0156V24.0234ZM44.0339 24.0234H40.0312V28.026H44.0339V24.0234Z" fill="#424242"/>
</g>
<defs>
<clipPath id="clip0">
<rect width="53" height="36" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="58" height="36"><path fill="#F0EFF1" d="M54 32v-28h-50v28h50zm-16-2h-18v-6h18v6zm6 0h-4v-6h4v6zm8 0h-6v-6h6v6zm-4-24h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm-6-12h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm-6-12h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm-6-12h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm-6-12h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm-6-12h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm0 12h-4v-6h4v6zm-6-24h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm-6-12h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h4v4h-4v-4zm0 6h6v6h-6v-6z"/><path fill="#424242" d="M55.336 0h-53.285c-1.344 0-2.051.656-2.051 2v32c0 1.344.707 1.965 2.051 1.965l53.949.035c1.344 0 2-.656 2-2v-32c0-1.344-1.32-2-2.664-2zm-1.336 32h-50v-28h50v28z"/><rect x="6" y="12" fill="#424242" width="4" height="4"/><rect x="12" y="12" fill="#424242" width="4" height="4"/><rect x="18" y="12" fill="#424242" width="4" height="4"/><rect x="24" y="12" fill="#424242" width="4" height="4"/><rect x="30" y="12" fill="#424242" width="4" height="4"/><rect x="36" y="12" fill="#424242" width="4" height="4"/><rect x="42" y="12" fill="#424242" width="4" height="4"/><rect x="48" y="12" fill="#424242" width="4" height="4"/><rect x="6" y="6" fill="#424242" width="4" height="4"/><rect x="12" y="6" fill="#424242" width="4" height="4"/><rect x="18" y="6" fill="#424242" width="4" height="4"/><rect x="24" y="6" fill="#424242" width="4" height="4"/><rect x="30" y="6" fill="#424242" width="4" height="4"/><rect x="36" y="6" fill="#424242" width="4" height="4"/><rect x="42" y="6" fill="#424242" width="4" height="4"/><rect x="48" y="6" fill="#424242" width="4" height="4"/><rect x="6" y="18" fill="#424242" width="4" height="4"/><rect x="12" y="18" fill="#424242" width="4" height="4"/><rect x="18" y="18" fill="#424242" width="4" height="4"/><rect x="24" y="18" fill="#424242" width="4" height="4"/><rect x="30" y="18" fill="#424242" width="4" height="4"/><rect x="36" y="18" fill="#424242" width="4" height="4"/><rect x="42" y="18" fill="#424242" width="4" height="4"/><rect x="48" y="18" fill="#424242" width="4" height="4"/><rect x="6" y="24" fill="#424242" width="6" height="6"/><rect x="46" y="24" fill="#424242" width="6" height="6"/><rect x="20" y="24" fill="#424242" width="18" height="6"/><rect x="14" y="24" fill="#424242" width="4" height="6"/><rect x="40" y="24" fill="#424242" width="4" height="6"/></svg>

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -8,7 +8,7 @@ import * as dom from 'vs/base/browser/dom';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { Emitter, Event } from 'vs/base/common/event';
import { Keybinding, ResolvedKeybinding, SimpleKeybinding, createKeybinding } from 'vs/base/common/keyCodes';
import { IDisposable, IReference, ImmortalReference, combinedDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { IDisposable, IReference, ImmortalReference, toDisposable, DisposableStore, Disposable } from 'vs/base/common/lifecycle';
import { OS, isLinux, isMacintosh } from 'vs/base/common/platform';
import Severity from 'vs/base/common/severity';
import { URI } from 'vs/base/common/uri';
@@ -25,7 +25,7 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import { IResolvedTextEditorModel, ITextModelContentProvider, ITextModelService } from 'vs/editor/common/services/resolverService';
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
import { CommandsRegistry, ICommand, ICommandEvent, ICommandHandler, ICommandService } from 'vs/platform/commands/common/commands';
import { IConfigurationChangeEvent, IConfigurationData, IConfigurationOverrides, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IConfigurationChangeEvent, IConfigurationData, IConfigurationOverrides, IConfigurationService, IConfigurationModel } from 'vs/platform/configuration/common/configuration';
import { Configuration, ConfigurationModel, DefaultConfigurationModel } from 'vs/platform/configuration/common/configurationModels';
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IConfirmation, IConfirmationResult, IDialogOptions, IDialogService } from 'vs/platform/dialogs/common/dialogs';
@@ -37,13 +37,14 @@ import { IKeybindingItem, KeybindingsRegistry } from 'vs/platform/keybinding/com
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding';
import { ILabelService, ResourceLabelFormatter } from 'vs/platform/label/common/label';
import { INotification, INotificationHandle, INotificationService, IPromptChoice, IPromptOptions, NoOpNotification } from 'vs/platform/notification/common/notification';
import { IProgressRunner, IProgressService } from 'vs/platform/progress/common/progress';
import { INotification, INotificationHandle, INotificationService, IPromptChoice, IPromptOptions, NoOpNotification, IStatusMessageOptions } from 'vs/platform/notification/common/notification';
import { IProgressRunner, IEditorProgressService } from 'vs/platform/progress/common/progress';
import { ITelemetryInfo, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspace, IWorkspaceContextService, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, WorkbenchState, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { ILayoutService, IDimension } from 'vs/platform/layout/browser/layoutService';
import { SimpleServicesNLS } from 'vs/editor/common/standaloneStrings';
import { ClassifiedEvent, StrictPropertyCheck, GDPRClassification } from 'vs/platform/telemetry/common/gdprTypings';
export class SimpleModel implements IResolvedTextEditorModel {
@@ -136,7 +137,7 @@ export class SimpleEditorModelResolverService implements ITextModelService {
}
}
export class SimpleProgressService implements IProgressService {
export class SimpleEditorProgressService implements IEditorProgressService {
_serviceBrand: any;
private static NULL_PROGRESS_RUNNER: IProgressRunner = {
@@ -148,7 +149,7 @@ export class SimpleProgressService implements IProgressService {
show(infinite: true, delay?: number): IProgressRunner;
show(total: number, delay?: number): IProgressRunner;
show(): IProgressRunner {
return SimpleProgressService.NULL_PROGRESS_RUNNER;
return SimpleEditorProgressService.NULL_PROGRESS_RUNNER;
}
showWhile(promise: Promise<any>, delay?: number): Promise<void> {
@@ -220,6 +221,10 @@ export class SimpleNotificationService implements INotificationService {
public prompt(severity: Severity, message: string, choices: IPromptChoice[], options?: IPromptOptions): INotificationHandle {
return SimpleNotificationService.NO_OP;
}
public status(message: string | Error, options?: IStatusMessageOptions): IDisposable {
return Disposable.None;
}
}
export class StandaloneCommandService implements ICommandService {
@@ -291,7 +296,7 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
throw new Error(`Invalid keybinding`);
}
let toDispose: IDisposable[] = [];
const toDispose = new DisposableStore();
this._dynamicKeybindings.push({
keybinding: keybinding,
@@ -301,7 +306,7 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
weight2: 0
});
toDispose.push(toDisposable(() => {
toDispose.add(toDisposable(() => {
for (let i = 0; i < this._dynamicKeybindings.length; i++) {
let kb = this._dynamicKeybindings[i];
if (kb.command === commandId) {
@@ -314,7 +319,7 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
let commandService = this._commandService;
if (commandService instanceof StandaloneCommandService) {
toDispose.push(commandService.addCommand({
toDispose.add(commandService.addCommand({
id: commandId,
handler: handler
}));
@@ -323,7 +328,7 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
}
this.updateResolver({ source: KeybindingSource.Default });
return combinedDisposable(toDispose);
return toDispose;
}
private updateResolver(event: IKeybindingEvent): void {
@@ -386,6 +391,10 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
public _dumpDebugInfo(): string {
return '';
}
public _dumpDebugInfoJSON(): string {
return '';
}
}
function isConfigurationOverrides(thing: any): thing is IConfigurationOverrides {
@@ -446,7 +455,17 @@ export class SimpleConfigurationService implements IConfigurationService {
}
public getConfigurationData(): IConfigurationData | null {
return null;
const emptyModel: IConfigurationModel = {
contents: {},
keys: [],
overrides: []
};
return {
defaults: emptyModel,
user: emptyModel,
workspace: emptyModel,
folders: {}
};
}
}
@@ -507,6 +526,10 @@ export class StandaloneTelemetryService implements ITelemetryService {
return Promise.resolve(undefined);
}
publicLog2<E extends ClassifiedEvent<T> = never, T extends GDPRClassification<T> = never>(eventName: string, data?: StrictPropertyCheck<T, E>) {
return this.publicLog(eventName, data as any);
}
public getTelemetryInfo(): Promise<ITelemetryInfo> {
throw new Error(`Not available`);
}

View File

@@ -5,7 +5,7 @@
import * as browser from 'vs/base/browser/browser';
import * as aria from 'vs/base/browser/ui/aria/aria';
import { Disposable, IDisposable, combinedDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { Disposable, IDisposable, toDisposable, DisposableStore } from 'vs/base/common/lifecycle';
import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
@@ -227,13 +227,13 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
};
let toDispose: IDisposable[] = [];
const toDispose = new DisposableStore();
// Generate a unique id to allow the same descriptor.id across multiple editor instances
const uniqueId = this.getId() + ':' + id;
// Register the command
toDispose.push(CommandsRegistry.registerCommand(uniqueId, run));
toDispose.add(CommandsRegistry.registerCommand(uniqueId, run));
// Register the context menu item
if (contextMenuGroupId) {
@@ -246,16 +246,14 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
group: contextMenuGroupId,
order: contextMenuOrder
};
toDispose.push(MenuRegistry.appendMenuItem(MenuId.EditorContext, menuItem));
toDispose.add(MenuRegistry.appendMenuItem(MenuId.EditorContext, menuItem));
}
// Register the keybindings
if (Array.isArray(keybindings)) {
toDispose = toDispose.concat(
keybindings.map((kb) => {
return this._standaloneKeybindingService.addDynamicKeybinding(uniqueId, kb, run, keybindingsWhen);
})
);
for (const kb of keybindings) {
toDispose.add(this._standaloneKeybindingService.addDynamicKeybinding(uniqueId, kb, run, keybindingsWhen));
}
}
// Finally, register an internal editor action
@@ -270,11 +268,11 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
// Store it under the original id, such that trigger with the original id will work
this._actions[id] = internalAction;
toDispose.push(toDisposable(() => {
toDispose.add(toDisposable(() => {
delete this._actions[id];
}));
return combinedDisposable(toDispose);
return toDispose;
}
}

View File

@@ -152,15 +152,13 @@ export function createModel(value: string, language?: string, uri?: URI): ITextM
value = value || '';
if (!language) {
let path = uri ? uri.path : null;
let firstLF = value.indexOf('\n');
let firstLine = value;
if (firstLF !== -1) {
firstLine = value.substring(0, firstLF);
}
return doCreateModel(value, StaticServices.modeService.get().createByFilepathOrFirstLine(path, firstLine), uri);
return doCreateModel(value, StaticServices.modeService.get().createByFilepathOrFirstLine(uri || null, firstLine), uri);
}
return doCreateModel(value, StaticServices.modeService.get().create(language), uri);
}
@@ -354,6 +352,7 @@ export function createMonacoEditorAPI(): typeof monaco.editor {
ScrollbarVisibility: standaloneEnums.ScrollbarVisibility,
WrappingIndent: standaloneEnums.WrappingIndent,
OverviewRulerLane: standaloneEnums.OverviewRulerLane,
MinimapPosition: standaloneEnums.MinimapPosition,
EndOfLinePreference: standaloneEnums.EndOfLinePreference,
DefaultEndOfLine: standaloneEnums.DefaultEndOfLine,
EndOfLineSequence: standaloneEnums.EndOfLineSequence,

View File

@@ -250,7 +250,7 @@ export interface IEncodedLineTokens {
* - f = foreground ColorId (9 bits)
* - b = background ColorId (9 bits)
* - The color value for each colorId is defined in IStandaloneThemeData.customTokenColors:
* e.g colorId = 1 is stored in IStandaloneThemeData.customTokenColors[1]. Color id = 0 means no color,
* e.g. colorId = 1 is stored in IStandaloneThemeData.customTokenColors[1]. Color id = 0 means no color,
* id = 1 is for the default foreground color, id = 2 for the default background.
*/
tokens: Uint32Array;
@@ -290,14 +290,11 @@ export interface EncodedTokensProvider {
}
function isEncodedTokensProvider(provider: TokensProvider | EncodedTokensProvider): provider is EncodedTokensProvider {
return provider['tokenizeEncoded'];
return 'tokenizeEncoded' in provider;
}
function isThenable<T>(obj: any): obj is Thenable<T> {
if (typeof obj.then === 'function') {
return true;
}
return false;
return obj && typeof obj.then === 'function';
}
/**
@@ -427,7 +424,7 @@ export function registerCodeLensProvider(languageId: string, provider: modes.Cod
*/
export function registerCodeActionProvider(languageId: string, provider: CodeActionProvider): IDisposable {
return modes.CodeActionProviderRegistry.register(languageId, {
provideCodeActions: (model: model.ITextModel, range: Range, context: modes.CodeActionContext, token: CancellationToken): (modes.Command | modes.CodeAction)[] | Promise<(modes.Command | modes.CodeAction)[]> => {
provideCodeActions: (model: model.ITextModel, range: Range, context: modes.CodeActionContext, token: CancellationToken): modes.CodeActionList | Promise<modes.CodeActionList> => {
let markers = StaticServices.markerService.get().read({ resource: model.uri }).filter(m => {
return Range.areIntersectingOrTouching(m, range);
});
@@ -510,7 +507,7 @@ export interface CodeActionProvider {
/**
* Provide commands for the given document and range.
*/
provideCodeActions(model: model.ITextModel, range: Range, context: CodeActionContext, token: CancellationToken): (modes.Command | modes.CodeAction)[] | Promise<(modes.Command | modes.CodeAction)[]>;
provideCodeActions(model: model.ITextModel, range: Range, context: CodeActionContext, token: CancellationToken): modes.CodeActionList | Promise<modes.CodeActionList>;
}
/**

View File

@@ -13,7 +13,7 @@ import { ModeServiceImpl } from 'vs/editor/common/services/modeServiceImpl';
import { IModelService } from 'vs/editor/common/services/modelService';
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
import { ITextResourceConfigurationService, ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
import { SimpleBulkEditService, SimpleConfigurationService, SimpleDialogService, SimpleNotificationService, SimpleProgressService, SimpleResourceConfigurationService, SimpleResourcePropertiesService, SimpleUriLabelService, SimpleWorkspaceContextService, StandaloneCommandService, StandaloneKeybindingService, StandaloneTelemetryService, SimpleLayoutService } from 'vs/editor/standalone/browser/simpleServices';
import { SimpleBulkEditService, SimpleConfigurationService, SimpleDialogService, SimpleNotificationService, SimpleEditorProgressService, SimpleResourceConfigurationService, SimpleResourcePropertiesService, SimpleUriLabelService, SimpleWorkspaceContextService, StandaloneCommandService, StandaloneKeybindingService, StandaloneTelemetryService, SimpleLayoutService } from 'vs/editor/standalone/browser/simpleServices';
import { StandaloneCodeEditorServiceImpl } from 'vs/editor/standalone/browser/standaloneCodeServiceImpl';
import { StandaloneThemeServiceImpl } from 'vs/editor/standalone/browser/standaloneThemeServiceImpl';
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
@@ -36,7 +36,7 @@ import { ILogService, NullLogService } from 'vs/platform/log/common/log';
import { MarkerService } from 'vs/platform/markers/common/markerService';
import { IMarkerService } from 'vs/platform/markers/common/markers';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { IEditorProgressService } from 'vs/platform/progress/common/progress';
import { IStorageService, InMemoryStorageService } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IThemeService } from 'vs/platform/theme/common/themeService';
@@ -44,11 +44,10 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import { MenuService } from 'vs/platform/actions/common/menuService';
import { IMarkerDecorationsService } from 'vs/editor/common/services/markersDecorationService';
import { MarkerDecorationsService } from 'vs/editor/common/services/markerDecorationsServiceImpl';
import { ISuggestMemoryService, SuggestMemoryService } from 'vs/editor/contrib/suggest/suggestMemory';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { BrowserAccessibilityService } from 'vs/platform/accessibility/common/accessibilityService';
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
import { ICodeLensCache, CodeLensCache } from 'vs/editor/contrib/codelens/codeLensCache';
import { getSingletonServiceDescriptors } from 'vs/platform/instantiation/common/extensions';
export interface IEditorOverrideServices {
[index: string]: any;
@@ -100,6 +99,11 @@ export module StaticServices {
// Create a fresh service collection
let result = new ServiceCollection();
// make sure to add all services that use `registerSingleton`
for (const [id, descriptor] of getSingletonServiceDescriptors()) {
result.set(id, descriptor);
}
// Initialize the service collection with the overrides
for (let serviceId in overrides) {
if (overrides.hasOwnProperty(serviceId)) {
@@ -150,17 +154,13 @@ export module StaticServices {
export const codeEditorService = define(ICodeEditorService, (o) => new StandaloneCodeEditorServiceImpl(standaloneThemeService.get(o)));
export const progressService = define(IProgressService, () => new SimpleProgressService());
export const editorProgressService = define(IEditorProgressService, () => new SimpleEditorProgressService());
export const storageService = define(IStorageService, () => new InMemoryStorageService());
export const logService = define(ILogService, () => new NullLogService());
export const editorWorkerService = define(IEditorWorkerService, (o) => new EditorWorkerServiceImpl(modelService.get(o), resourceConfigurationService.get(o), logService.get(o)));
export const suggestMemoryService = define(ISuggestMemoryService, (o) => new SuggestMemoryService(storageService.get(o), configurationService.get(o)));
export const codeLensCacheService = define(ICodeLensCache, (o) => new CodeLensCache(storageService.get(o)));
}
export class DynamicStandaloneServices extends Disposable {

View File

@@ -27,7 +27,7 @@ class StandaloneTheme implements IStandaloneTheme {
public readonly themeName: string;
private readonly themeData: IStandaloneThemeData;
private colors: { [colorId: string]: Color } | null;
private colors: Map<string, Color> | null;
private readonly defaultColors: { [colorId: string]: Color | undefined; };
private _tokenTheme: TokenTheme | null;
@@ -57,19 +57,18 @@ class StandaloneTheme implements IStandaloneTheme {
}
}
private getColors(): { [colorId: string]: Color } {
private getColors(): Map<string, Color> {
if (!this.colors) {
let colors: { [colorId: string]: Color } = Object.create(null);
const colors = new Map<string, Color>();
for (let id in this.themeData.colors) {
colors[id] = Color.fromHex(this.themeData.colors[id]);
colors.set(id, Color.fromHex(this.themeData.colors[id]));
}
if (this.themeData.inherit) {
let baseData = getBuiltinRules(this.themeData.base);
for (let id in baseData.colors) {
if (!colors[id]) {
colors[id] = Color.fromHex(baseData.colors[id]);
if (!colors.has(id)) {
colors.set(id, Color.fromHex(baseData.colors[id]));
}
}
}
this.colors = colors;
@@ -78,7 +77,7 @@ class StandaloneTheme implements IStandaloneTheme {
}
public getColor(colorId: ColorIdentifier, useDefault?: boolean): Color | undefined {
const color = this.getColors()[colorId];
const color = this.getColors().get(colorId);
if (color) {
return color;
}