mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge VS Code 1.31.1 (#4283)
This commit is contained in:
@@ -77,7 +77,7 @@ const nlsSingleSelection = nls.localize("singleSelection", "Line {0}, Column {1}
|
||||
const nlsMultiSelectionRange = nls.localize("multiSelectionRange", "{0} selections ({1} characters selected)");
|
||||
const nlsMultiSelection = nls.localize("multiSelection", "{0} selections");
|
||||
|
||||
function getSelectionLabel(selections: Selection[] | null, charactersSelected: number): string | null {
|
||||
function getSelectionLabel(selections: Selection[] | null, charactersSelected: number): string {
|
||||
if (!selections || selections.length === 0) {
|
||||
return nlsNoSelection;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ function getSelectionLabel(selections: Selection[] | null, charactersSelected: n
|
||||
return strings.format(nlsMultiSelection, selections.length);
|
||||
}
|
||||
|
||||
return null;
|
||||
return '';
|
||||
}
|
||||
|
||||
class AccessibilityHelpWidget extends Widget implements IOverlayWidget {
|
||||
|
||||
@@ -35,7 +35,7 @@ export class QuickOpenController implements editorCommon.IEditorContribution, ID
|
||||
private rangeHighlightDecorationId: string;
|
||||
private lastKnownEditorSelection: Selection;
|
||||
|
||||
constructor(editor: ICodeEditor, @IThemeService private themeService: IThemeService) {
|
||||
constructor(editor: ICodeEditor, @IThemeService private readonly themeService: IThemeService) {
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,7 @@ interface ParseResult {
|
||||
}
|
||||
|
||||
export class GotoLineEntry extends QuickOpenEntry {
|
||||
|
||||
private _parseResult: ParseResult;
|
||||
private parseResult: ParseResult;
|
||||
private decorator: IDecorator;
|
||||
private editor: editorCommon.IEditor;
|
||||
|
||||
@@ -35,14 +34,12 @@ export class GotoLineEntry extends QuickOpenEntry {
|
||||
|
||||
this.editor = editor;
|
||||
this.decorator = decorator;
|
||||
this._parseResult = this._parseInput(line);
|
||||
this.parseResult = this.parseInput(line);
|
||||
}
|
||||
|
||||
|
||||
private _parseInput(line: string): ParseResult {
|
||||
|
||||
let numbers = line.split(',').map(part => parseInt(part, 10)).filter(part => !isNaN(part)),
|
||||
position: Position;
|
||||
private parseInput(line: string): ParseResult {
|
||||
const numbers = line.split(',').map(part => parseInt(part, 10)).filter(part => !isNaN(part));
|
||||
let position: Position;
|
||||
|
||||
if (numbers.length === 0) {
|
||||
position = new Position(-1, -1);
|
||||
@@ -59,8 +56,8 @@ export class GotoLineEntry extends QuickOpenEntry {
|
||||
model = (<IDiffEditor>this.editor).getModel().modified;
|
||||
}
|
||||
|
||||
let isValid = model.validatePosition(position).equals(position),
|
||||
label: string;
|
||||
const isValid = model.validatePosition(position).equals(position);
|
||||
let label: string;
|
||||
|
||||
if (isValid) {
|
||||
if (position.column && position.column > 1) {
|
||||
@@ -81,15 +78,17 @@ export class GotoLineEntry extends QuickOpenEntry {
|
||||
};
|
||||
}
|
||||
|
||||
public getLabel(): string {
|
||||
return this._parseResult.label;
|
||||
getLabel(): string {
|
||||
return this.parseResult.label;
|
||||
}
|
||||
|
||||
public getAriaLabel(): string {
|
||||
return nls.localize('gotoLineAriaLabel', "Go to line {0}", this._parseResult.label);
|
||||
getAriaLabel(): string {
|
||||
const currentLine = this.editor.getPosition().lineNumber;
|
||||
|
||||
return nls.localize('gotoLineAriaLabel', "Current Line: {0}. Go to line {0}.", currentLine, this.parseResult.label);
|
||||
}
|
||||
|
||||
public run(mode: Mode, context: IContext): boolean {
|
||||
run(mode: Mode, context: IContext): boolean {
|
||||
if (mode === Mode.OPEN) {
|
||||
return this.runOpen();
|
||||
}
|
||||
@@ -97,15 +96,15 @@ export class GotoLineEntry extends QuickOpenEntry {
|
||||
return this.runPreview();
|
||||
}
|
||||
|
||||
public runOpen(): boolean {
|
||||
runOpen(): boolean {
|
||||
|
||||
// No-op if range is not valid
|
||||
if (!this._parseResult.isValid) {
|
||||
if (!this.parseResult.isValid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Apply selection and focus
|
||||
let range = this.toSelection();
|
||||
const range = this.toSelection();
|
||||
(<ICodeEditor>this.editor).setSelection(range);
|
||||
(<ICodeEditor>this.editor).revealRangeInCenter(range, editorCommon.ScrollType.Smooth);
|
||||
this.editor.focus();
|
||||
@@ -113,16 +112,16 @@ export class GotoLineEntry extends QuickOpenEntry {
|
||||
return true;
|
||||
}
|
||||
|
||||
public runPreview(): boolean {
|
||||
runPreview(): boolean {
|
||||
|
||||
// No-op if range is not valid
|
||||
if (!this._parseResult.isValid) {
|
||||
if (!this.parseResult.isValid) {
|
||||
this.decorator.clearDecorations();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Select Line Position
|
||||
let range = this.toSelection();
|
||||
const range = this.toSelection();
|
||||
this.editor.revealRangeInCenter(range, editorCommon.ScrollType.Smooth);
|
||||
|
||||
// Decorate if possible
|
||||
@@ -133,10 +132,10 @@ export class GotoLineEntry extends QuickOpenEntry {
|
||||
|
||||
private toSelection(): Range {
|
||||
return new Range(
|
||||
this._parseResult.position.lineNumber,
|
||||
this._parseResult.position.column,
|
||||
this._parseResult.position.lineNumber,
|
||||
this._parseResult.position.column
|
||||
this.parseResult.position.lineNumber,
|
||||
this.parseResult.position.column,
|
||||
this.parseResult.position.lineNumber,
|
||||
this.parseResult.position.column
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -158,7 +157,7 @@ export class GotoLineAction extends BaseEditorQuickOpenAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
run(accessor: ServicesAccessor, editor: ICodeEditor): void {
|
||||
this._show(this.getController(editor), {
|
||||
getModel: (value: string): QuickOpenModel => {
|
||||
return new QuickOpenModel([new GotoLineEntry(value, editor, this.getController(editor))]);
|
||||
|
||||
@@ -61,7 +61,7 @@ export class EditorActionCommandEntry extends QuickOpenEntryGroup {
|
||||
|
||||
try {
|
||||
let promise = this.action.run() || Promise.resolve();
|
||||
promise.then(null, onUnexpectedError);
|
||||
promise.then(undefined, onUnexpectedError);
|
||||
} catch (error) {
|
||||
onUnexpectedError(error);
|
||||
}
|
||||
@@ -122,8 +122,7 @@ export class QuickCommandAction extends BaseEditorQuickOpenAction {
|
||||
let actions: IEditorAction[] = editor.getSupportedActions();
|
||||
let entries: EditorActionCommandEntry[] = [];
|
||||
|
||||
for (let i = 0; i < actions.length; i++) {
|
||||
let action = actions[i];
|
||||
for (const action of actions) {
|
||||
|
||||
let keybinding = keybindingService.lookupKeybinding(action.id);
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): Thenable<void> {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
|
||||
|
||||
let model = editor.getModel();
|
||||
|
||||
@@ -181,8 +181,7 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
|
||||
normalizedSearchValue = normalizedSearchValue.substr(SCOPE_PREFIX.length);
|
||||
}
|
||||
|
||||
for (let i = 0; i < flattened.length; i++) {
|
||||
let element = flattened[i];
|
||||
for (const element of flattened) {
|
||||
let label = strings.trim(element.name);
|
||||
|
||||
// Check for meatch
|
||||
|
||||
@@ -36,7 +36,7 @@ import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingReso
|
||||
import { IKeybindingItem, KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
|
||||
import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding';
|
||||
import { ILabelService, LabelRules, RegisterFormatterEvent } from 'vs/platform/label/common/label';
|
||||
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 { ITelemetryInfo, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
@@ -57,7 +57,7 @@ export class SimpleModel implements ITextEditorModel {
|
||||
return this._onDispose.event;
|
||||
}
|
||||
|
||||
public load(): Thenable<SimpleModel> {
|
||||
public load(): Promise<SimpleModel> {
|
||||
return Promise.resolve(this);
|
||||
}
|
||||
|
||||
@@ -116,6 +116,10 @@ export class SimpleEditorModelResolverService implements ITextModelService {
|
||||
};
|
||||
}
|
||||
|
||||
public hasTextModelContentProvider(scheme: string): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
private findModel(editor: ICodeEditor, resource: URI): ITextModel | null {
|
||||
let model = editor.getModel();
|
||||
if (model && model.uri.toString() !== resource.toString()) {
|
||||
@@ -135,14 +139,14 @@ export class SimpleProgressService implements IProgressService {
|
||||
worked: () => { }
|
||||
};
|
||||
|
||||
show(infinite: boolean, delay?: number): IProgressRunner;
|
||||
show(infinite: true, delay?: number): IProgressRunner;
|
||||
show(total: number, delay?: number): IProgressRunner;
|
||||
show(): IProgressRunner {
|
||||
return SimpleProgressService.NULL_PROGRESS_RUNNER;
|
||||
}
|
||||
|
||||
showWhile(promise: Thenable<any>, delay?: number): Thenable<void> {
|
||||
return Promise.resolve(void 0);
|
||||
showWhile(promise: Promise<any>, delay?: number): Promise<void> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +154,7 @@ export class SimpleDialogService implements IDialogService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
|
||||
public confirm(confirmation: IConfirmation): Thenable<IConfirmationResult> {
|
||||
public confirm(confirmation: IConfirmation): Promise<IConfirmationResult> {
|
||||
return this.doConfirm(confirmation).then(confirmed => {
|
||||
return {
|
||||
confirmed,
|
||||
@@ -159,7 +163,7 @@ export class SimpleDialogService implements IDialogService {
|
||||
});
|
||||
}
|
||||
|
||||
private doConfirm(confirmation: IConfirmation): Thenable<boolean> {
|
||||
private doConfirm(confirmation: IConfirmation): Promise<boolean> {
|
||||
let messageText = confirmation.message;
|
||||
if (confirmation.detail) {
|
||||
messageText = messageText + '\n\n' + confirmation.detail;
|
||||
@@ -168,7 +172,7 @@ export class SimpleDialogService implements IDialogService {
|
||||
return Promise.resolve(window.confirm(messageText));
|
||||
}
|
||||
|
||||
public show(severity: Severity, message: string, buttons: string[], options?: IDialogOptions): Thenable<number> {
|
||||
public show(severity: Severity, message: string, buttons: string[], options?: IDialogOptions): Promise<number> {
|
||||
return Promise.resolve(0);
|
||||
}
|
||||
}
|
||||
@@ -218,7 +222,7 @@ export class StandaloneCommandService implements ICommandService {
|
||||
private readonly _instantiationService: IInstantiationService;
|
||||
private _dynamicCommands: { [id: string]: ICommand; };
|
||||
|
||||
private readonly _onWillExecuteCommand: Emitter<ICommandEvent> = new Emitter<ICommandEvent>();
|
||||
private readonly _onWillExecuteCommand = new Emitter<ICommandEvent>();
|
||||
public readonly onWillExecuteCommand: Event<ICommandEvent> = this._onWillExecuteCommand.event;
|
||||
|
||||
constructor(instantiationService: IInstantiationService) {
|
||||
@@ -242,7 +246,7 @@ export class StandaloneCommandService implements ICommandService {
|
||||
|
||||
try {
|
||||
this._onWillExecuteCommand.fire({ commandId: id });
|
||||
const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler].concat(args));
|
||||
const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler, ...args]) as T;
|
||||
return Promise.resolve(result);
|
||||
} catch (err) {
|
||||
return Promise.reject(err);
|
||||
@@ -336,8 +340,7 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
|
||||
|
||||
private _toNormalizedKeybindingItems(items: IKeybindingItem[], isDefault: boolean): ResolvedKeybindingItem[] {
|
||||
let result: ResolvedKeybindingItem[] = [], resultLen = 0;
|
||||
for (let i = 0, len = items.length; i < len; i++) {
|
||||
const item = items[i];
|
||||
for (const item of items) {
|
||||
const when = (item.when ? item.when.normalize() : null);
|
||||
const keybinding = item.keybinding;
|
||||
|
||||
@@ -346,8 +349,8 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
|
||||
result[resultLen++] = new ResolvedKeybindingItem(null, item.command, item.commandArgs, when, isDefault);
|
||||
} else {
|
||||
const resolvedKeybindings = this.resolveKeybinding(keybinding);
|
||||
for (let j = 0; j < resolvedKeybindings.length; j++) {
|
||||
result[resultLen++] = new ResolvedKeybindingItem(resolvedKeybindings[j], item.command, item.commandArgs, when, isDefault);
|
||||
for (const resolvedKeybinding of resolvedKeybindings) {
|
||||
result[resultLen++] = new ResolvedKeybindingItem(resolvedKeybinding, item.command, item.commandArgs, when, isDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,7 +407,7 @@ export class SimpleConfigurationService implements IConfigurationService {
|
||||
getValue<T>(overrides: IConfigurationOverrides): T;
|
||||
getValue<T>(section: string, overrides: IConfigurationOverrides): T;
|
||||
getValue(arg1?: any, arg2?: any): any {
|
||||
const section = typeof arg1 === 'string' ? arg1 : void 0;
|
||||
const section = typeof arg1 === 'string' ? arg1 : undefined;
|
||||
const overrides = isConfigurationOverrides(arg1) ? arg1 : isConfigurationOverrides(arg2) ? arg2 : {};
|
||||
return this.configuration().getValue(section, overrides, null);
|
||||
}
|
||||
@@ -429,7 +432,7 @@ export class SimpleConfigurationService implements IConfigurationService {
|
||||
}
|
||||
|
||||
public reloadConfiguration(): Promise<void> {
|
||||
return Promise.resolve(void 0);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public getConfigurationData(): IConfigurationData | null {
|
||||
@@ -454,7 +457,7 @@ export class SimpleResourceConfigurationService implements ITextResourceConfigur
|
||||
getValue<T>(resource: URI, position?: IPosition, section?: string): T;
|
||||
getValue<T>(resource: any, arg2?: any, arg3?: any) {
|
||||
const position: IPosition | null = Pos.isIPosition(arg2) ? arg2 : null;
|
||||
const section: string | undefined = position ? (typeof arg3 === 'string' ? arg3 : void 0) : (typeof arg2 === 'string' ? arg2 : void 0);
|
||||
const section: string | undefined = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
|
||||
if (typeof section === 'undefined') {
|
||||
return this.configurationService.getValue<T>();
|
||||
}
|
||||
@@ -467,7 +470,7 @@ export class SimpleResourcePropertiesService implements ITextResourcePropertiesS
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -488,7 +491,7 @@ export class StandaloneTelemetryService implements ITelemetryService {
|
||||
public isOptedIn = false;
|
||||
|
||||
public publicLog(eventName: string, data?: any): Promise<void> {
|
||||
return Promise.resolve(void 0);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
public getTelemetryInfo(): Promise<ITelemetryInfo> {
|
||||
@@ -502,13 +505,13 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService {
|
||||
|
||||
private static SCHEME = 'inmemory';
|
||||
|
||||
private readonly _onDidChangeWorkspaceName: Emitter<void> = new Emitter<void>();
|
||||
private readonly _onDidChangeWorkspaceName = new Emitter<void>();
|
||||
public readonly onDidChangeWorkspaceName: Event<void> = this._onDidChangeWorkspaceName.event;
|
||||
|
||||
private readonly _onDidChangeWorkspaceFolders: Emitter<IWorkspaceFoldersChangeEvent> = new Emitter<IWorkspaceFoldersChangeEvent>();
|
||||
private readonly _onDidChangeWorkspaceFolders = new Emitter<IWorkspaceFoldersChangeEvent>();
|
||||
public readonly onDidChangeWorkspaceFolders: Event<IWorkspaceFoldersChangeEvent> = this._onDidChangeWorkspaceFolders.event;
|
||||
|
||||
private readonly _onDidChangeWorkbenchState: Emitter<WorkbenchState> = new Emitter<WorkbenchState>();
|
||||
private readonly _onDidChangeWorkbenchState = new Emitter<WorkbenchState>();
|
||||
public readonly onDidChangeWorkbenchState: Event<WorkbenchState> = this._onDidChangeWorkbenchState.event;
|
||||
|
||||
private readonly workspace: IWorkspace;
|
||||
@@ -518,6 +521,10 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService {
|
||||
this.workspace = { id: '4064f6ec-cb38-4ad0-af64-ee6467e63c82', folders: [new WorkspaceFolder({ uri: resource, name: '', index: 0 })] };
|
||||
}
|
||||
|
||||
getCompleteWorkspace(): Promise<IWorkspace> {
|
||||
return Promise.resolve(this.getWorkspace());
|
||||
}
|
||||
|
||||
public getWorkspace(): IWorkspace {
|
||||
return this.workspace;
|
||||
}
|
||||
@@ -608,8 +615,8 @@ export class SimpleBulkEditService implements IBulkEditService {
|
||||
export class SimpleUriLabelService implements ILabelService {
|
||||
_serviceBrand: any;
|
||||
|
||||
private readonly _onDidRegisterFormatter: Emitter<RegisterFormatterEvent> = new Emitter<RegisterFormatterEvent>();
|
||||
public readonly onDidRegisterFormatter: Event<RegisterFormatterEvent> = this._onDidRegisterFormatter.event;
|
||||
private readonly _onDidRegisterFormatter = new Emitter<void>();
|
||||
public readonly onDidChangeFormatters: Event<void> = this._onDidRegisterFormatter.event;
|
||||
|
||||
public getUriLabel(resource: URI, options?: { relative?: boolean, forceNoTildify?: boolean }): string {
|
||||
if (resource.scheme === 'file') {
|
||||
@@ -622,7 +629,7 @@ export class SimpleUriLabelService implements ILabelService {
|
||||
return '';
|
||||
}
|
||||
|
||||
public registerFormatter(selector: string, formatter: LabelRules): IDisposable {
|
||||
public registerFormatter(formatter: ResourceLabelFormatter): IDisposable {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
||||
|
||||
@@ -122,13 +122,13 @@ export interface IDiffEditorConstructionOptions extends IDiffEditorOptions {
|
||||
}
|
||||
|
||||
export interface IStandaloneCodeEditor extends ICodeEditor {
|
||||
addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null;
|
||||
addCommand(keybinding: number, handler: ICommandHandler, context?: string): string | null;
|
||||
createContextKey<T>(key: string, defaultValue: T): IContextKey<T>;
|
||||
addAction(descriptor: IActionDescriptor): IDisposable;
|
||||
}
|
||||
|
||||
export interface IStandaloneDiffEditor extends IDiffEditor {
|
||||
addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null;
|
||||
addCommand(keybinding: number, handler: ICommandHandler, context?: string): string | null;
|
||||
createContextKey<T>(key: string, defaultValue: T): IContextKey<T>;
|
||||
addAction(descriptor: IActionDescriptor): IDisposable;
|
||||
|
||||
@@ -182,7 +182,7 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
|
||||
createAriaDomNode();
|
||||
}
|
||||
|
||||
public addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null {
|
||||
public addCommand(keybinding: number, handler: ICommandHandler, context?: string): string | null {
|
||||
if (!this._standaloneKeybindingService) {
|
||||
console.warn('Cannot add command because the editor is configured with an unrecognized KeybindingService');
|
||||
return null;
|
||||
@@ -360,7 +360,7 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
|
||||
|
||||
constructor(
|
||||
domElement: HTMLElement,
|
||||
options: IDiffEditorConstructionOptions,
|
||||
options: IDiffEditorConstructionOptions | undefined,
|
||||
toDispose: IDisposable,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@@ -409,7 +409,7 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
|
||||
return <StandaloneCodeEditor>super.getModifiedEditor();
|
||||
}
|
||||
|
||||
public addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null {
|
||||
public addCommand(keybinding: number, handler: ICommandHandler, context?: string): string | null {
|
||||
return this.getModifiedEditor().addCommand(keybinding, handler, context);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export class StandaloneCodeEditorServiceImpl extends CodeEditorServiceImpl {
|
||||
return null; // not supported in the standalone case
|
||||
}
|
||||
|
||||
public openCodeEditor(input: IResourceInput, source: ICodeEditor | null, sideBySide?: boolean): Thenable<ICodeEditor | null> {
|
||||
public openCodeEditor(input: IResourceInput, source: ICodeEditor | null, sideBySide?: boolean): Promise<ICodeEditor | null> {
|
||||
if (!source) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ import { IMarker, IMarkerData } from 'vs/platform/markers/common/markers';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
|
||||
type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
function withAllStandaloneServices<T extends editorCommon.IEditor>(domElement: HTMLElement, override: IEditorOverrideServices, callback: (services: DynamicStandaloneServices) => T): T {
|
||||
let services = new DynamicStandaloneServices(domElement, override);
|
||||
|
||||
@@ -100,7 +102,7 @@ export function onDidCreateEditor(listener: (codeEditor: ICodeEditor) => void):
|
||||
* The editor will read the size of `domElement`.
|
||||
*/
|
||||
export function createDiffEditor(domElement: HTMLElement, options?: IDiffEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneDiffEditor {
|
||||
return withAllStandaloneServices(domElement, override, (services) => {
|
||||
return withAllStandaloneServices(domElement, override || {}, (services) => {
|
||||
return new StandaloneDiffEditor(
|
||||
domElement,
|
||||
options,
|
||||
@@ -178,8 +180,8 @@ export function setModelMarkers(model: ITextModel, owner: string, markers: IMark
|
||||
|
||||
/**
|
||||
* Get markers for owner and/or resource
|
||||
* @returns {IMarker[]} list of markers
|
||||
* @param filter
|
||||
*
|
||||
* @returns list of markers
|
||||
*/
|
||||
export function getModelMarkers(filter: { owner?: string, resource?: URI, take?: number }): IMarker[] {
|
||||
return StaticServices.markerService.get().read(filter);
|
||||
@@ -260,15 +262,14 @@ export function colorizeModelLine(model: ITextModel, lineNumber: number, tabSize
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function getSafeTokenizationSupport(language: string): modes.ITokenizationSupport {
|
||||
function getSafeTokenizationSupport(language: string): Omit<modes.ITokenizationSupport, 'tokenize2'> {
|
||||
let tokenizationSupport = modes.TokenizationRegistry.get(language);
|
||||
if (tokenizationSupport) {
|
||||
return tokenizationSupport;
|
||||
}
|
||||
return {
|
||||
getInitialState: () => NULL_STATE,
|
||||
tokenize: (line: string, state: modes.IState, deltaOffset: number) => nullTokenize(language, line, state, deltaOffset),
|
||||
tokenize2: undefined,
|
||||
tokenize: (line: string, state: modes.IState, deltaOffset: number) => nullTokenize(language, line, state, deltaOffset)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -345,10 +345,10 @@ export function registerSignatureHelpProvider(languageId: string, provider: mode
|
||||
*/
|
||||
export function registerHoverProvider(languageId: string, provider: modes.HoverProvider): IDisposable {
|
||||
return modes.HoverProviderRegistry.register(languageId, {
|
||||
provideHover: (model: model.ITextModel, position: Position, token: CancellationToken): Thenable<modes.Hover> => {
|
||||
provideHover: (model: model.ITextModel, position: Position, token: CancellationToken): Promise<modes.Hover | undefined> => {
|
||||
let word = model.getWordAtPosition(position);
|
||||
|
||||
return Promise.resolve<modes.Hover | null | undefined>(provider.provideHover(model, position, token)).then((value) => {
|
||||
return Promise.resolve<modes.Hover | null | undefined>(provider.provideHover(model, position, token)).then((value): modes.Hover | undefined => {
|
||||
if (!value) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -411,7 +411,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)[] | Thenable<(modes.Command | modes.CodeAction)[]> => {
|
||||
provideCodeActions: (model: model.ITextModel, range: Range, context: modes.CodeActionContext, token: CancellationToken): (modes.Command | modes.CodeAction)[] | Promise<(modes.Command | modes.CodeAction)[]> => {
|
||||
let markers = StaticServices.markerService.get().read({ resource: model.uri }).filter(m => {
|
||||
return Range.areIntersectingOrTouching(m, range);
|
||||
});
|
||||
@@ -477,8 +477,6 @@ export interface CodeActionContext {
|
||||
|
||||
/**
|
||||
* An array of diagnostics.
|
||||
*
|
||||
* @readonly
|
||||
*/
|
||||
readonly markers: IMarkerData[];
|
||||
|
||||
@@ -496,7 +494,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)[] | Thenable<(modes.Command | modes.CodeAction)[]>;
|
||||
provideCodeActions(model: model.ITextModel, range: Range, context: CodeActionContext, token: CancellationToken): (modes.Command | modes.CodeAction)[] | Promise<(modes.Command | modes.CodeAction)[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,6 +42,9 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
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';
|
||||
|
||||
export interface IEditorOverrideServices {
|
||||
[index: string]: any;
|
||||
@@ -53,12 +56,12 @@ export module StaticServices {
|
||||
|
||||
export class LazyStaticService<T> {
|
||||
private _serviceId: ServiceIdentifier<T>;
|
||||
private _factory: (overrides: IEditorOverrideServices) => T;
|
||||
private _value: T;
|
||||
private _factory: (overrides?: IEditorOverrideServices) => T;
|
||||
private _value: T | null;
|
||||
|
||||
public get id() { return this._serviceId; }
|
||||
|
||||
constructor(serviceId: ServiceIdentifier<T>, factory: (overrides: IEditorOverrideServices) => T) {
|
||||
constructor(serviceId: ServiceIdentifier<T>, factory: (overrides?: IEditorOverrideServices) => T) {
|
||||
this._serviceId = serviceId;
|
||||
this._factory = factory;
|
||||
this._value = null;
|
||||
@@ -133,7 +136,9 @@ export module StaticServices {
|
||||
|
||||
export const modeService = define(IModeService, (o) => new ModeServiceImpl());
|
||||
|
||||
export const modelService = define(IModelService, (o) => new ModelServiceImpl(markerService.get(o), configurationService.get(o), resourcePropertiesService.get(o)));
|
||||
export const modelService = define(IModelService, (o) => new ModelServiceImpl(configurationService.get(o), resourcePropertiesService.get(o)));
|
||||
|
||||
export const markerDecorationsService = define(IMarkerDecorationsService, (o) => new MarkerDecorationsService(modelService.get(o), markerService.get(o)));
|
||||
|
||||
export const editorWorkerService = define(IEditorWorkerService, (o) => new EditorWorkerServiceImpl(modelService.get(o), resourceConfigurationService.get(o)));
|
||||
|
||||
@@ -147,6 +152,8 @@ export module StaticServices {
|
||||
|
||||
export const logService = define(ILogService, () => new NullLogService());
|
||||
|
||||
export const suggestMemoryService = define(ISuggestMemoryService, (o) => new SuggestMemoryService(storageService.get(o), configurationService.get(o)));
|
||||
|
||||
}
|
||||
|
||||
export class DynamicStandaloneServices extends Disposable {
|
||||
|
||||
@@ -212,9 +212,9 @@ export class StandaloneThemeServiceImpl implements IStandaloneThemeService {
|
||||
public setTheme(themeName: string): string {
|
||||
let theme: StandaloneTheme;
|
||||
if (this._knownThemes.has(themeName)) {
|
||||
theme = this._knownThemes.get(themeName);
|
||||
theme = this._knownThemes.get(themeName)!;
|
||||
} else {
|
||||
theme = this._knownThemes.get(VS_THEME_NAME);
|
||||
theme = this._knownThemes.get(VS_THEME_NAME)!;
|
||||
}
|
||||
if (this._theme === theme) {
|
||||
// Nothing to do
|
||||
|
||||
Reference in New Issue
Block a user