mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from master
This commit is contained in:
@@ -2,35 +2,34 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./accessibilityHelp';
|
||||
import * as nls from 'vs/nls';
|
||||
import * as browser from 'vs/base/browser/browser';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import { renderFormattedText } from 'vs/base/browser/htmlContentRenderer';
|
||||
import { alert } from 'vs/base/browser/ui/aria/aria';
|
||||
import { Widget } from 'vs/base/browser/ui/widget';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { renderFormattedText } from 'vs/base/browser/htmlContentRenderer';
|
||||
import { FastDomNode, createFastDomNode } from 'vs/base/browser/fastDomNode';
|
||||
import { Widget } from 'vs/base/browser/ui/widget';
|
||||
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { RawContextKey, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction, EditorCommand, registerEditorAction, registerEditorCommand, registerEditorContribution } from 'vs/editor/browser/editorExtensions';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { IEditorContribution } from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { registerEditorAction, registerEditorContribution, EditorAction, EditorCommand, registerEditorCommand } from 'vs/editor/browser/editorExtensions';
|
||||
import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition } from 'vs/editor/browser/editorBrowser';
|
||||
import { ToggleTabFocusModeAction } from 'vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode';
|
||||
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
import { editorWidgetBackground, widgetShadow, contrastBorder } from 'vs/platform/theme/common/colorRegistry';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { alert } from 'vs/base/browser/ui/aria/aria';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import * as browser from 'vs/base/browser/browser';
|
||||
import { IEditorConstructionOptions } from 'vs/editor/standalone/browser/standaloneCodeEditor';
|
||||
import { IContextKey, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
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 { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
const CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE = new RawContextKey<boolean>('accessibilityHelpWidgetVisible', false);
|
||||
|
||||
@@ -78,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[], charactersSelected: number): string {
|
||||
function getSelectionLabel(selections: Selection[] | null, charactersSelected: number): string | null {
|
||||
if (!selections || selections.length === 0) {
|
||||
return nlsNoSelection;
|
||||
}
|
||||
@@ -258,13 +257,13 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget {
|
||||
}
|
||||
}
|
||||
|
||||
const turnOnMessage = (
|
||||
platform.isMacintosh
|
||||
? nls.localize("changeConfigToOnMac", "To configure the editor to be optimized for usage with a Screen Reader press Command+E now.")
|
||||
: nls.localize("changeConfigToOnWinLinux", "To configure the editor to be optimized for usage with a Screen Reader press Control+E now.")
|
||||
);
|
||||
switch (opts.accessibilitySupport) {
|
||||
case platform.AccessibilitySupport.Unknown:
|
||||
const turnOnMessage = (
|
||||
platform.isMacintosh
|
||||
? nls.localize("changeConfigToOnMac", "To configure the editor to be optimized for usage with a Screen Reader press Command+E now.")
|
||||
: nls.localize("changeConfigToOnWinLinux", "To configure the editor to be optimized for usage with a Screen Reader press Control+E now.")
|
||||
);
|
||||
text += '\n\n - ' + turnOnMessage;
|
||||
break;
|
||||
case platform.AccessibilitySupport.Enabled:
|
||||
@@ -376,17 +375,17 @@ registerEditorCommand(
|
||||
);
|
||||
|
||||
registerThemingParticipant((theme, collector) => {
|
||||
let widgetBackground = theme.getColor(editorWidgetBackground);
|
||||
const widgetBackground = theme.getColor(editorWidgetBackground);
|
||||
if (widgetBackground) {
|
||||
collector.addRule(`.monaco-editor .accessibilityHelpWidget { background-color: ${widgetBackground}; }`);
|
||||
}
|
||||
|
||||
let widgetShadowColor = theme.getColor(widgetShadow);
|
||||
const widgetShadowColor = theme.getColor(widgetShadow);
|
||||
if (widgetShadowColor) {
|
||||
collector.addRule(`.monaco-editor .accessibilityHelpWidget { box-shadow: 0 2px 8px ${widgetShadowColor}; }`);
|
||||
}
|
||||
|
||||
let hcBorder = theme.getColor(contrastBorder);
|
||||
const hcBorder = theme.getColor(contrastBorder);
|
||||
if (hcBorder) {
|
||||
collector.addRule(`.monaco-editor .accessibilityHelpWidget { border: 2px solid ${hcBorder}; }`);
|
||||
}
|
||||
|
||||
@@ -2,18 +2,17 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { TimeoutTimer } from 'vs/base/common/async';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { ColorId, MetadataConsts, FontStyle, TokenizationRegistry, ITokenizationSupport } from 'vs/editor/common/modes';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { renderViewLine2 as renderViewLine, RenderLineInput } from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
import { LineTokens, IViewLineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { IViewLineTokens, LineTokens } from 'vs/editor/common/core/lineTokens';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { ColorId, FontStyle, ITokenizationSupport, MetadataConsts, TokenizationRegistry } from 'vs/editor/common/modes';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { RenderLineInput, renderViewLine2 as renderViewLine } from 'vs/editor/common/viewLayout/viewLineRenderer';
|
||||
import { ViewLineRenderingData } from 'vs/editor/common/viewModel/viewModel';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
|
||||
export interface IColorizerOptions {
|
||||
tabSize?: number;
|
||||
@@ -26,71 +25,76 @@ export interface IColorizerElementOptions extends IColorizerOptions {
|
||||
|
||||
export class Colorizer {
|
||||
|
||||
public static colorizeElement(themeService: IStandaloneThemeService, modeService: IModeService, domNode: HTMLElement, options: IColorizerElementOptions): TPromise<void> {
|
||||
public static colorizeElement(themeService: IStandaloneThemeService, modeService: IModeService, domNode: HTMLElement, options: IColorizerElementOptions): Promise<void> {
|
||||
options = options || {};
|
||||
let theme = options.theme || 'vs';
|
||||
let mimeType = options.mimeType || domNode.getAttribute('lang') || domNode.getAttribute('data-lang');
|
||||
if (!mimeType) {
|
||||
console.error('Mode not detected');
|
||||
return undefined;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
themeService.setTheme(theme);
|
||||
|
||||
let text = domNode.firstChild.nodeValue;
|
||||
let text = domNode.firstChild ? domNode.firstChild.nodeValue : '';
|
||||
domNode.className += ' ' + theme;
|
||||
let render = (str: string) => {
|
||||
domNode.innerHTML = str;
|
||||
};
|
||||
return this.colorize(modeService, text, mimeType, options).then(render, (err) => console.error(err));
|
||||
return this.colorize(modeService, text || '', mimeType, options).then(render, (err) => console.error(err));
|
||||
}
|
||||
|
||||
private static _tokenizationSupportChangedPromise(language: string): TPromise<void> {
|
||||
let listener: IDisposable = null;
|
||||
let stopListening = () => {
|
||||
if (listener) {
|
||||
listener.dispose();
|
||||
listener = null;
|
||||
}
|
||||
};
|
||||
public static colorize(modeService: IModeService, text: string, mimeType: string, options: IColorizerOptions | null | undefined): Promise<string> {
|
||||
let tabSize = 4;
|
||||
if (options && typeof options.tabSize === 'number') {
|
||||
tabSize = options.tabSize;
|
||||
}
|
||||
|
||||
return new TPromise<void>((c, e) => {
|
||||
listener = TokenizationRegistry.onDidChange((e) => {
|
||||
if (e.changedLanguages.indexOf(language) >= 0) {
|
||||
stopListening();
|
||||
c(void 0);
|
||||
}
|
||||
});
|
||||
}, stopListening);
|
||||
}
|
||||
|
||||
public static colorize(modeService: IModeService, text: string, mimeType: string, options: IColorizerOptions): TPromise<string> {
|
||||
if (strings.startsWithUTF8BOM(text)) {
|
||||
text = text.substr(1);
|
||||
}
|
||||
let lines = text.split(/\r\n|\r|\n/);
|
||||
let language = modeService.getModeId(mimeType);
|
||||
|
||||
options = options || {};
|
||||
if (typeof options.tabSize === 'undefined') {
|
||||
options.tabSize = 4;
|
||||
if (!language) {
|
||||
return Promise.resolve(_fakeColorize(lines, tabSize));
|
||||
}
|
||||
|
||||
// Send out the event to create the mode
|
||||
modeService.getOrCreateMode(language);
|
||||
modeService.triggerMode(language);
|
||||
|
||||
let tokenizationSupport = TokenizationRegistry.get(language);
|
||||
if (tokenizationSupport) {
|
||||
return TPromise.as(_colorize(lines, options.tabSize, tokenizationSupport));
|
||||
return Promise.resolve(_colorize(lines, tabSize, tokenizationSupport));
|
||||
}
|
||||
|
||||
// wait 500ms for mode to load, then give up
|
||||
return TPromise.any([this._tokenizationSupportChangedPromise(language), TPromise.timeout(500)]).then(_ => {
|
||||
let tokenizationSupport = TokenizationRegistry.get(language);
|
||||
if (tokenizationSupport) {
|
||||
return _colorize(lines, options.tabSize, tokenizationSupport);
|
||||
}
|
||||
return _fakeColorize(lines, options.tabSize);
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
let listener: IDisposable | null = null;
|
||||
let timeout: TimeoutTimer | null = null;
|
||||
|
||||
const execute = () => {
|
||||
if (listener) {
|
||||
listener.dispose();
|
||||
listener = null;
|
||||
}
|
||||
if (timeout) {
|
||||
timeout.dispose();
|
||||
timeout = null;
|
||||
}
|
||||
const tokenizationSupport = TokenizationRegistry.get(language!);
|
||||
if (tokenizationSupport) {
|
||||
return resolve(_colorize(lines, tabSize, tokenizationSupport));
|
||||
}
|
||||
return resolve(_fakeColorize(lines, tabSize));
|
||||
};
|
||||
|
||||
// wait 500ms for mode to load, then give up
|
||||
timeout = new TimeoutTimer();
|
||||
timeout.cancelAndSet(execute, 500);
|
||||
listener = TokenizationRegistry.onDidChange((e) => {
|
||||
if (e.changedLanguages.indexOf(language!) >= 0) {
|
||||
execute();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -99,6 +103,7 @@ export class Colorizer {
|
||||
const containsRTL = ViewLineRenderingData.containsRTL(line, isBasicASCII, mightContainRTL);
|
||||
let renderResult = renderViewLine(new RenderLineInput(
|
||||
false,
|
||||
true,
|
||||
line,
|
||||
false,
|
||||
isBasicASCII,
|
||||
@@ -152,6 +157,7 @@ function _fakeColorize(lines: string[], tabSize: number): string {
|
||||
const containsRTL = ViewLineRenderingData.containsRTL(line, isBasicASCII, /* check for RTL */true);
|
||||
let renderResult = renderViewLine(new RenderLineInput(
|
||||
false,
|
||||
true,
|
||||
line,
|
||||
false,
|
||||
isBasicASCII,
|
||||
@@ -187,6 +193,7 @@ function _actualColorize(lines: string[], tabSize: number, tokenizationSupport:
|
||||
const containsRTL = ViewLineRenderingData.containsRTL(line, isBasicASCII, /* check for RTL */true);
|
||||
let renderResult = renderViewLine(new RenderLineInput(
|
||||
false,
|
||||
true,
|
||||
line,
|
||||
false,
|
||||
isBasicASCII,
|
||||
|
||||
@@ -3,22 +3,20 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./iPadShowKeyboard';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import * as browser from 'vs/base/browser/browser';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { IEditorContribution } from 'vs/editor/common/editorCommon';
|
||||
import { IDisposable, dispose } 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 {
|
||||
|
||||
private static readonly ID = 'editor.contrib.iPadShowKeyboard';
|
||||
|
||||
private editor: ICodeEditor;
|
||||
private widget: ShowKeyboardWidget;
|
||||
private widget: ShowKeyboardWidget | null;
|
||||
private toDispose: IDisposable[];
|
||||
|
||||
constructor(editor: ICodeEditor) {
|
||||
@@ -31,14 +29,13 @@ export class IPadShowKeyboard implements IEditorContribution {
|
||||
}
|
||||
|
||||
private update(): void {
|
||||
const hasWidget = (!!this.widget);
|
||||
const shouldHaveWidget = (!this.editor.getConfiguration().readOnly);
|
||||
|
||||
if (!hasWidget && shouldHaveWidget) {
|
||||
if (!this.widget && shouldHaveWidget) {
|
||||
|
||||
this.widget = new ShowKeyboardWidget(this.editor);
|
||||
|
||||
} else if (hasWidget && !shouldHaveWidget) {
|
||||
} else if (this.widget && !shouldHaveWidget) {
|
||||
|
||||
this.widget.dispose();
|
||||
this.widget = null;
|
||||
|
||||
@@ -2,26 +2,25 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./inspectTokens';
|
||||
import * as nls from 'vs/nls';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { escape } from 'vs/base/common/strings';
|
||||
import { ContentWidgetPositionPreference, IActiveCodeEditor, ICodeEditor, IContentWidget, IContentWidgetPosition } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction, ServicesAccessor, registerEditorAction, registerEditorContribution } from 'vs/editor/browser/editorExtensions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Token } from 'vs/editor/common/core/token';
|
||||
import { IEditorContribution } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { registerEditorAction, registerEditorContribution, EditorAction, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { ICodeEditor, ContentWidgetPositionPreference, IContentWidget, IContentWidgetPosition } from 'vs/editor/browser/editorBrowser';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { TokenizationRegistry, LanguageIdentifier, FontStyle, StandardTokenType, ITokenizationSupport, IState, TokenMetadata } from 'vs/editor/common/modes';
|
||||
import { CharCode } from 'vs/base/common/charCode';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { FontStyle, IState, ITokenizationSupport, LanguageIdentifier, StandardTokenType, TokenMetadata, TokenizationRegistry } from 'vs/editor/common/modes';
|
||||
import { NULL_STATE, nullTokenize, nullTokenize2 } from 'vs/editor/common/modes/nullMode';
|
||||
import { Token } from 'vs/editor/common/core/token';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { registerThemingParticipant, HIGH_CONTRAST } from 'vs/platform/theme/common/themeService';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { editorHoverBackground, editorHoverBorder } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { HIGH_CONTRAST, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
|
||||
class InspectTokensController extends Disposable implements IEditorContribution {
|
||||
@@ -33,9 +32,8 @@ class InspectTokensController extends Disposable implements IEditorContribution
|
||||
}
|
||||
|
||||
private _editor: ICodeEditor;
|
||||
private _standaloneThemeService: IStandaloneThemeService;
|
||||
private _modeService: IModeService;
|
||||
private _widget: InspectTokensWidget;
|
||||
private _widget: InspectTokensWidget | null;
|
||||
|
||||
constructor(
|
||||
editor: ICodeEditor,
|
||||
@@ -44,7 +42,6 @@ class InspectTokensController extends Disposable implements IEditorContribution
|
||||
) {
|
||||
super();
|
||||
this._editor = editor;
|
||||
this._standaloneThemeService = standaloneColorService;
|
||||
this._modeService = modeService;
|
||||
this._widget = null;
|
||||
|
||||
@@ -66,10 +63,10 @@ class InspectTokensController extends Disposable implements IEditorContribution
|
||||
if (this._widget) {
|
||||
return;
|
||||
}
|
||||
if (!this._editor.getModel()) {
|
||||
if (!this._editor.hasModel()) {
|
||||
return;
|
||||
}
|
||||
this._widget = new InspectTokensWidget(this._editor, this._standaloneThemeService, this._modeService);
|
||||
this._widget = new InspectTokensWidget(this._editor, this._modeService);
|
||||
}
|
||||
|
||||
public stop(): void {
|
||||
@@ -165,15 +162,14 @@ class InspectTokensWidget extends Disposable implements IContentWidget {
|
||||
// Editor.IContentWidget.allowEditorOverflow
|
||||
public allowEditorOverflow = true;
|
||||
|
||||
private _editor: ICodeEditor;
|
||||
private _editor: IActiveCodeEditor;
|
||||
private _modeService: IModeService;
|
||||
private _tokenizationSupport: ITokenizationSupport;
|
||||
private _model: ITextModel;
|
||||
private _domNode: HTMLElement;
|
||||
|
||||
constructor(
|
||||
editor: ICodeEditor,
|
||||
standaloneThemeService: IStandaloneThemeService,
|
||||
editor: IActiveCodeEditor,
|
||||
modeService: IModeService
|
||||
) {
|
||||
super();
|
||||
@@ -250,14 +246,14 @@ class InspectTokensWidget extends Disposable implements IContentWidget {
|
||||
}
|
||||
|
||||
private _decodeMetadata(metadata: number): IDecodedMetadata {
|
||||
let colorMap = TokenizationRegistry.getColorMap();
|
||||
let colorMap = TokenizationRegistry.getColorMap()!;
|
||||
let languageId = TokenMetadata.getLanguageId(metadata);
|
||||
let tokenType = TokenMetadata.getTokenType(metadata);
|
||||
let fontStyle = TokenMetadata.getFontStyle(metadata);
|
||||
let foreground = TokenMetadata.getForeground(metadata);
|
||||
let background = TokenMetadata.getBackground(metadata);
|
||||
return {
|
||||
languageIdentifier: this._modeService.getLanguageIdentifier(languageId),
|
||||
languageIdentifier: this._modeService.getLanguageIdentifier(languageId)!,
|
||||
tokenType: tokenType,
|
||||
fontStyle: fontStyle,
|
||||
foreground: colorMap[foreground],
|
||||
@@ -333,13 +329,13 @@ registerEditorContribution(InspectTokensController);
|
||||
registerEditorAction(InspectTokens);
|
||||
|
||||
registerThemingParticipant((theme, collector) => {
|
||||
let border = theme.getColor(editorHoverBorder);
|
||||
const border = theme.getColor(editorHoverBorder);
|
||||
if (border) {
|
||||
let borderWidth = theme.type === HIGH_CONTRAST ? 2 : 1;
|
||||
collector.addRule(`.monaco-editor .tokens-inspect-widget { border: ${borderWidth}px solid ${border}; }`);
|
||||
collector.addRule(`.monaco-editor .tokens-inspect-widget .tokens-inspect-separator { background-color: ${border}; }`);
|
||||
}
|
||||
let background = theme.getColor(editorHoverBackground);
|
||||
const background = theme.getColor(editorHoverBackground);
|
||||
if (background) {
|
||||
collector.addRule(`.monaco-editor .tokens-inspect-widget { background-color: ${background}; }`);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
.monaco-quick-open-widget .monaco-tree .monaco-tree-row .monaco-highlighted-label .highlight,
|
||||
.monaco-quick-open-widget .monaco-list .monaco-list-row .monaco-highlighted-label .highlight {
|
||||
color: #0066BF;
|
||||
}
|
||||
|
||||
.vs-dark .monaco-quick-open-widget .monaco-tree .monaco-tree-row .monaco-highlighted-label .highlight,
|
||||
.vs-dark .monaco-quick-open-widget .monaco-list .monaco-list-row .monaco-highlighted-label .highlight {
|
||||
color: #0097fb;
|
||||
}
|
||||
|
||||
.hc-black .monaco-quick-open-widget .monaco-tree .monaco-tree-row .monaco-highlighted-label .highlight,
|
||||
.hc-black .monaco-quick-open-widget .monaco-list .monaco-list-row .monaco-highlighted-label .highlight {
|
||||
color: #F38518;
|
||||
}
|
||||
@@ -2,19 +2,19 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./editorQuickOpen';
|
||||
import { QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
|
||||
import { IAutoFocus } from 'vs/base/parts/quickopen/common/quickOpen';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { QuickOpenEditorWidget } from './quickOpenEditorWidget';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { registerEditorContribution, IActionOptions, EditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { EditorAction, IActionOptions, registerEditorContribution } from 'vs/editor/browser/editorExtensions';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { IModelDeltaDecoration } from 'vs/editor/common/model';
|
||||
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
|
||||
import { QuickOpenEditorWidget } from 'vs/editor/standalone/browser/quickOpen/quickOpenEditorWidget';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
export interface IQuickOpenControllerOpts {
|
||||
inputAriaLabel: string;
|
||||
@@ -69,7 +69,13 @@ export class QuickOpenController implements editorCommon.IEditorContribution, ID
|
||||
}
|
||||
|
||||
this.lastKnownEditorSelection = null;
|
||||
this.editor.focus();
|
||||
|
||||
// Return focus to the editor if
|
||||
// - focus is back on the <body> element because no other focusable element was clicked
|
||||
// - a command was picked from the picker which indicates the editor should get focused
|
||||
if (document.activeElement === document.body || !canceled) {
|
||||
this.editor.focus();
|
||||
}
|
||||
};
|
||||
|
||||
this.widget = new QuickOpenEditorWidget(
|
||||
|
||||
@@ -3,21 +3,19 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./gotoLine';
|
||||
import * as nls from 'vs/nls';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { IContext, QuickOpenEntry, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
|
||||
import { IAutoFocus, Mode } from 'vs/base/parts/quickopen/common/quickOpen';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { ICodeEditor, IDiffEditor, isCodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { BaseEditorQuickOpenAction, IDecorator } from './editorQuickOpen';
|
||||
import { registerEditorAction, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { BaseEditorQuickOpenAction, IDecorator } from 'vs/editor/standalone/browser/quickOpen/editorQuickOpen';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
|
||||
interface ParseResult {
|
||||
|
||||
@@ -2,33 +2,33 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import * as browser from 'vs/base/browser/browser';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { matchesFuzzy } from 'vs/base/common/filters';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { IContext, IHighlight, QuickOpenEntryGroup, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
|
||||
import { IAutoFocus, Mode } from 'vs/base/parts/quickopen/common/quickOpen';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IEditorAction, IEditor } from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { BaseEditorQuickOpenAction } from './editorQuickOpen';
|
||||
import { registerEditorAction, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import * as browser from 'vs/base/browser/browser';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { IEditor, IEditorAction } from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { BaseEditorQuickOpenAction } from 'vs/editor/standalone/browser/quickOpen/editorQuickOpen';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
|
||||
export class EditorActionCommandEntry extends QuickOpenEntryGroup {
|
||||
private key: string;
|
||||
private action: IEditorAction;
|
||||
private editor: IEditor;
|
||||
private keyAriaLabel: string;
|
||||
|
||||
constructor(key: string, highlights: IHighlight[], action: IEditorAction, editor: IEditor) {
|
||||
constructor(key: string, keyAriaLabel: string, highlights: IHighlight[], action: IEditorAction, editor: IEditor) {
|
||||
super();
|
||||
|
||||
this.key = key;
|
||||
this.keyAriaLabel = keyAriaLabel;
|
||||
this.setHighlights(highlights);
|
||||
this.action = action;
|
||||
this.editor = editor;
|
||||
@@ -39,6 +39,10 @@ export class EditorActionCommandEntry extends QuickOpenEntryGroup {
|
||||
}
|
||||
|
||||
public getAriaLabel(): string {
|
||||
if (this.keyAriaLabel) {
|
||||
return nls.localize('ariaLabelEntryWithKey', "{0}, {1}, commands", this.getLabel(), this.keyAriaLabel);
|
||||
}
|
||||
|
||||
return nls.localize('ariaLabelEntry', "{0}, commands", this.getLabel());
|
||||
}
|
||||
|
||||
@@ -50,18 +54,18 @@ export class EditorActionCommandEntry extends QuickOpenEntryGroup {
|
||||
if (mode === Mode.OPEN) {
|
||||
|
||||
// Use a timeout to give the quick open widget a chance to close itself first
|
||||
TPromise.timeout(50).done(() => {
|
||||
setTimeout(() => {
|
||||
|
||||
// Some actions are enabled only when editor has focus
|
||||
this.editor.focus();
|
||||
|
||||
try {
|
||||
let promise = this.action.run() || TPromise.as(null);
|
||||
promise.done(null, onUnexpectedError);
|
||||
let promise = this.action.run() || Promise.resolve();
|
||||
promise.then(null, onUnexpectedError);
|
||||
} catch (error) {
|
||||
onUnexpectedError(error);
|
||||
}
|
||||
}, onUnexpectedError);
|
||||
}, 50);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -121,12 +125,12 @@ export class QuickCommandAction extends BaseEditorQuickOpenAction {
|
||||
for (let i = 0; i < actions.length; i++) {
|
||||
let action = actions[i];
|
||||
|
||||
let keybind = keybindingService.lookupKeybinding(action.id);
|
||||
let keybinding = keybindingService.lookupKeybinding(action.id);
|
||||
|
||||
if (action.label) {
|
||||
let highlights = matchesFuzzy(searchValue, action.label);
|
||||
if (highlights) {
|
||||
entries.push(new EditorActionCommandEntry(keybind ? keybind.getLabel() : '', highlights, action, editor));
|
||||
entries.push(new EditorActionCommandEntry(keybinding ? keybinding.getLabel() : '', keybinding ? keybinding.getAriaLabel() : '', highlights, action, editor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,16 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { Dimension } from 'vs/base/browser/dom';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
|
||||
import { QuickOpenWidget } from 'vs/base/parts/quickopen/browser/quickOpenWidget';
|
||||
import { IAutoFocus } from 'vs/base/parts/quickopen/common/quickOpen';
|
||||
import { ICodeEditor, IOverlayWidget, IOverlayWidgetPosition, OverlayWidgetPositionPreference } from 'vs/editor/browser/editorBrowser';
|
||||
import { attachQuickOpenStyler } from 'vs/platform/theme/common/styler';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { foreground } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { Dimension } from 'vs/base/browser/dom';
|
||||
import { attachQuickOpenStyler } from 'vs/platform/theme/common/styler';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
export interface IQuickOpenEditorWidgetOptions {
|
||||
inputAriaLabel: string;
|
||||
|
||||
@@ -3,25 +3,22 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./quickOutline';
|
||||
import * as nls from 'vs/nls';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { matchesFuzzy } from 'vs/base/common/filters';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IContext, IHighlight, QuickOpenEntryGroup, QuickOpenModel } from 'vs/base/parts/quickopen/browser/quickOpenModel';
|
||||
import { IAutoFocus, Mode } from 'vs/base/parts/quickopen/common/quickOpen';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { IRange, Range } from 'vs/editor/common/core/range';
|
||||
import { ScrollType } from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { DocumentSymbol, DocumentSymbolProviderRegistry, symbolKindToCssClass } from 'vs/editor/common/modes';
|
||||
import { BaseEditorQuickOpenAction, IDecorator } from './editorQuickOpen';
|
||||
import { getDocumentSymbols } from 'vs/editor/contrib/quickOpen/quickOpen';
|
||||
import { registerEditorAction, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { Range, IRange } from 'vs/editor/common/core/range';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { BaseEditorQuickOpenAction, IDecorator } from 'vs/editor/standalone/browser/quickOpen/editorQuickOpen';
|
||||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
|
||||
let SCOPE_PREFIX = ':';
|
||||
@@ -131,7 +128,7 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
|
||||
});
|
||||
}
|
||||
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): TPromise<void> {
|
||||
public run(accessor: ServicesAccessor, editor: ICodeEditor): Thenable<void> {
|
||||
|
||||
let model = editor.getModel();
|
||||
|
||||
@@ -140,7 +137,7 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
|
||||
}
|
||||
|
||||
// Resolve outline
|
||||
return getDocumentSymbols(model).then((result: DocumentSymbol[]) => {
|
||||
return getDocumentSymbols(model, true, CancellationToken.None).then((result: DocumentSymbol[]) => {
|
||||
if (result.length === 0) {
|
||||
return;
|
||||
}
|
||||
@@ -193,7 +190,7 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
|
||||
if (highlights) {
|
||||
|
||||
// Show parent scope as description
|
||||
let description: string = null;
|
||||
let description: string | null = null;
|
||||
if (element.containerName) {
|
||||
description = element.containerName;
|
||||
}
|
||||
@@ -214,8 +211,8 @@ export class QuickOutlineAction extends BaseEditorQuickOpenAction {
|
||||
|
||||
// Mark all type groups
|
||||
if (results.length > 0 && searchValue.indexOf(SCOPE_PREFIX) === 0) {
|
||||
let currentType: string = null;
|
||||
let currentResult: SymbolEntry = null;
|
||||
let currentType: string | null = null;
|
||||
let currentResult: SymbolEntry | null = null;
|
||||
let typeCounter = 0;
|
||||
|
||||
for (let i = 0; i < results.length; i++) {
|
||||
|
||||
@@ -2,17 +2,16 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { ReferencesController } from 'vs/editor/contrib/referenceSearch/referencesController';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
|
||||
export class StandaloneReferencesController extends ReferencesController {
|
||||
|
||||
@@ -33,7 +32,7 @@ export class StandaloneReferencesController extends ReferencesController {
|
||||
notificationService,
|
||||
instantiationService,
|
||||
storageService,
|
||||
configurationService,
|
||||
configurationService
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,49 +2,46 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IConfigurationService, IConfigurationChangeEvent, IConfigurationOverrides, IConfigurationData } from 'vs/platform/configuration/common/configuration';
|
||||
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { ICommandService, ICommand, ICommandEvent, ICommandHandler, CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { AbstractKeybindingService } from 'vs/platform/keybinding/common/abstractKeybindingService';
|
||||
import { USLayoutResolvedKeybinding } from 'vs/platform/keybinding/common/usLayoutResolvedKeybinding';
|
||||
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
import { IKeybindingEvent, KeybindingSource, IKeyboardEvent } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IWorkspaceContextService, IWorkspace, WorkbenchState, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { ICodeEditor, IDiffEditor, isCodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Configuration, DefaultConfigurationModel, ConfigurationModel } from 'vs/platform/configuration/common/configurationModels';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IProgressService, IProgressRunner } from 'vs/platform/progress/common/progress';
|
||||
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { ITextModelService, ITextModelContentProvider, ITextEditorModel } from 'vs/editor/common/services/resolverService';
|
||||
import { IDisposable, IReference, ImmortalReference, combinedDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { localize } from 'vs/nls';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeybindingsRegistry, IKeybindingItem } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { MenuId, IMenu, IMenuService } from 'vs/platform/actions/common/actions';
|
||||
import { Menu } from 'vs/platform/actions/common/menu';
|
||||
import { ITelemetryService, ITelemetryInfo } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { ResolvedKeybinding, Keybinding, createKeybinding, SimpleKeybinding } from 'vs/base/common/keyCodes';
|
||||
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem';
|
||||
import { OS } from 'vs/base/common/platform';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { INotificationService, INotification, INotificationHandle, NoOpNotification, IPromptChoice } from 'vs/platform/notification/common/notification';
|
||||
import { IConfirmation, IConfirmationResult, IDialogService, IDialogOptions } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IPosition, Position as Pos } from 'vs/editor/common/core/position';
|
||||
import { isEditorConfigurationKey, isDiffEditorConfigurationKey } from 'vs/editor/common/config/commonEditorConfig';
|
||||
import { IBulkEditService, IBulkEditOptions, IBulkEditResult } from 'vs/editor/browser/services/bulkEditService';
|
||||
import { WorkspaceEdit, isResourceTextEdit, TextEdit } from 'vs/editor/common/modes';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
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 { OS, isLinux, isMacintosh } from 'vs/base/common/platform';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ICodeEditor, IDiffEditor, isCodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { IBulkEditOptions, IBulkEditResult, IBulkEditService } from 'vs/editor/browser/services/bulkEditService';
|
||||
import { isDiffEditorConfigurationKey, isEditorConfigurationKey } from 'vs/editor/common/config/commonEditorConfig';
|
||||
import { EditOperation } from 'vs/editor/common/core/editOperation';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IPosition, Position as Pos } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { TextEdit, WorkspaceEdit, isResourceTextEdit } from 'vs/editor/common/modes';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { ITextEditorModel, 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 { 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';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { AbstractKeybindingService } from 'vs/platform/keybinding/common/abstractKeybindingService';
|
||||
import { IKeybindingEvent, IKeyboardEvent, KeybindingSource } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingResolver';
|
||||
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 { 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';
|
||||
import { IWorkspace, IWorkspaceContextService, IWorkspaceFolder, IWorkspaceFoldersChangeEvent, WorkbenchState, WorkspaceFolder } from 'vs/platform/workspace/common/workspace';
|
||||
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
|
||||
export class SimpleModel implements ITextEditorModel {
|
||||
|
||||
@@ -60,14 +57,18 @@ export class SimpleModel implements ITextEditorModel {
|
||||
return this._onDispose.event;
|
||||
}
|
||||
|
||||
public load(): TPromise<SimpleModel> {
|
||||
return TPromise.as(this);
|
||||
public load(): Thenable<SimpleModel> {
|
||||
return Promise.resolve(this);
|
||||
}
|
||||
|
||||
public get textEditorModel(): ITextModel {
|
||||
return this.model;
|
||||
}
|
||||
|
||||
public isReadonly(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
this._onDispose.fire();
|
||||
}
|
||||
@@ -96,19 +97,17 @@ export class SimpleEditorModelResolverService implements ITextModelService {
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
public createModelReference(resource: URI): TPromise<IReference<ITextEditorModel>> {
|
||||
let model: ITextModel;
|
||||
|
||||
model = withTypedEditor(this.editor,
|
||||
public createModelReference(resource: URI): Promise<IReference<ITextEditorModel>> {
|
||||
let model: ITextModel | null = withTypedEditor(this.editor,
|
||||
(editor) => this.findModel(editor, resource),
|
||||
(diffEditor) => this.findModel(diffEditor.getOriginalEditor(), resource) || this.findModel(diffEditor.getModifiedEditor(), resource)
|
||||
);
|
||||
|
||||
if (!model) {
|
||||
return TPromise.as(new ImmortalReference(null));
|
||||
return Promise.reject(new Error(`Model not found`));
|
||||
}
|
||||
|
||||
return TPromise.as(new ImmortalReference(new SimpleModel(model)));
|
||||
return Promise.resolve(new ImmortalReference(new SimpleModel(model)));
|
||||
}
|
||||
|
||||
public registerTextModelContentProvider(scheme: string, provider: ITextModelContentProvider): IDisposable {
|
||||
@@ -117,9 +116,9 @@ export class SimpleEditorModelResolverService implements ITextModelService {
|
||||
};
|
||||
}
|
||||
|
||||
private findModel(editor: ICodeEditor, resource: URI): ITextModel {
|
||||
private findModel(editor: ICodeEditor, resource: URI): ITextModel | null {
|
||||
let model = editor.getModel();
|
||||
if (model.uri.toString() !== resource.toString()) {
|
||||
if (model && model.uri.toString() !== resource.toString()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -142,8 +141,8 @@ export class SimpleProgressService implements IProgressService {
|
||||
return SimpleProgressService.NULL_PROGRESS_RUNNER;
|
||||
}
|
||||
|
||||
showWhile(promise: TPromise<any>, delay?: number): TPromise<void> {
|
||||
return null;
|
||||
showWhile(promise: Thenable<any>, delay?: number): Thenable<void> {
|
||||
return Promise.resolve(void 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,7 +150,7 @@ export class SimpleDialogService implements IDialogService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
|
||||
public confirm(confirmation: IConfirmation): TPromise<IConfirmationResult> {
|
||||
public confirm(confirmation: IConfirmation): Thenable<IConfirmationResult> {
|
||||
return this.doConfirm(confirmation).then(confirmed => {
|
||||
return {
|
||||
confirmed,
|
||||
@@ -160,17 +159,17 @@ export class SimpleDialogService implements IDialogService {
|
||||
});
|
||||
}
|
||||
|
||||
private doConfirm(confirmation: IConfirmation): TPromise<boolean> {
|
||||
private doConfirm(confirmation: IConfirmation): Thenable<boolean> {
|
||||
let messageText = confirmation.message;
|
||||
if (confirmation.detail) {
|
||||
messageText = messageText + '\n\n' + confirmation.detail;
|
||||
}
|
||||
|
||||
return TPromise.wrap(window.confirm(messageText));
|
||||
return Promise.resolve(window.confirm(messageText));
|
||||
}
|
||||
|
||||
public show(severity: Severity, message: string, buttons: string[], options?: IDialogOptions): TPromise<number> {
|
||||
return TPromise.as(0);
|
||||
public show(severity: Severity, message: string, buttons: string[], options?: IDialogOptions): Thenable<number> {
|
||||
return Promise.resolve(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +207,7 @@ export class SimpleNotificationService implements INotificationService {
|
||||
return SimpleNotificationService.NO_OP;
|
||||
}
|
||||
|
||||
public prompt(severity: Severity, message: string, choices: IPromptChoice[], onCancel?: () => void): INotificationHandle {
|
||||
public prompt(severity: Severity, message: string, choices: IPromptChoice[], options?: IPromptOptions): INotificationHandle {
|
||||
return SimpleNotificationService.NO_OP;
|
||||
}
|
||||
}
|
||||
@@ -235,24 +234,24 @@ export class StandaloneCommandService implements ICommandService {
|
||||
});
|
||||
}
|
||||
|
||||
public executeCommand<T>(id: string, ...args: any[]): TPromise<T> {
|
||||
public executeCommand<T>(id: string, ...args: any[]): Promise<T> {
|
||||
const command = (CommandsRegistry.getCommand(id) || this._dynamicCommands[id]);
|
||||
if (!command) {
|
||||
return TPromise.wrapError<T>(new Error(`command '${id}' not found`));
|
||||
return Promise.reject(new Error(`command '${id}' not found`));
|
||||
}
|
||||
|
||||
try {
|
||||
this._onWillExecuteCommand.fire({ commandId: id });
|
||||
const result = this._instantiationService.invokeFunction.apply(this._instantiationService, [command.handler].concat(args));
|
||||
return TPromise.as(result);
|
||||
return Promise.resolve(result);
|
||||
} catch (err) {
|
||||
return TPromise.wrapError<T>(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class StandaloneKeybindingService extends AbstractKeybindingService {
|
||||
private _cachedResolver: KeybindingResolver;
|
||||
private _cachedResolver: KeybindingResolver | null;
|
||||
private _dynamicKeybindings: IKeybindingItem[];
|
||||
|
||||
constructor(
|
||||
@@ -276,11 +275,16 @@ export class StandaloneKeybindingService extends AbstractKeybindingService {
|
||||
}));
|
||||
}
|
||||
|
||||
public addDynamicKeybinding(commandId: string, keybinding: number, handler: ICommandHandler, when: ContextKeyExpr): IDisposable {
|
||||
public addDynamicKeybinding(commandId: string, _keybinding: number, handler: ICommandHandler, when: ContextKeyExpr | null): IDisposable {
|
||||
const keybinding = createKeybinding(_keybinding, OS);
|
||||
if (!keybinding) {
|
||||
throw new Error(`Invalid keybinding`);
|
||||
}
|
||||
|
||||
let toDispose: IDisposable[] = [];
|
||||
|
||||
this._dynamicKeybindings.push({
|
||||
keybinding: createKeybinding(keybinding, OS),
|
||||
keybinding: keybinding,
|
||||
command: commandId,
|
||||
when: when,
|
||||
weight1: 1000,
|
||||
@@ -405,16 +409,16 @@ export class SimpleConfigurationService implements IConfigurationService {
|
||||
return this.configuration().getValue(section, overrides, null);
|
||||
}
|
||||
|
||||
public updateValue(key: string, value: any, arg3?: any, arg4?: any): TPromise<void> {
|
||||
public updateValue(key: string, value: any, arg3?: any, arg4?: any): Promise<void> {
|
||||
this.configuration().updateValue(key, value);
|
||||
return TPromise.as(null);
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
public inspect<C>(key: string, options: IConfigurationOverrides = {}): {
|
||||
default: C,
|
||||
user: C,
|
||||
workspace: C,
|
||||
workspaceFolder: C
|
||||
workspace?: C,
|
||||
workspaceFolder?: C
|
||||
value: C,
|
||||
} {
|
||||
return this.configuration().inspect<C>(key, options, null);
|
||||
@@ -424,11 +428,11 @@ export class SimpleConfigurationService implements IConfigurationService {
|
||||
return this.configuration().keys(null);
|
||||
}
|
||||
|
||||
public reloadConfiguration(): TPromise<void> {
|
||||
return TPromise.as(null);
|
||||
public reloadConfiguration(): Promise<void> {
|
||||
return Promise.resolve(void 0);
|
||||
}
|
||||
|
||||
public getConfigurationData(): IConfigurationData {
|
||||
public getConfigurationData(): IConfigurationData | null {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -449,24 +453,32 @@ export class SimpleResourceConfigurationService implements ITextResourceConfigur
|
||||
getValue<T>(resource: URI, section?: string): T;
|
||||
getValue<T>(resource: URI, position?: IPosition, section?: string): T;
|
||||
getValue<T>(resource: any, arg2?: any, arg3?: any) {
|
||||
const position: IPosition = Pos.isIPosition(arg2) ? arg2 : null;
|
||||
const section: string = position ? (typeof arg3 === 'string' ? arg3 : void 0) : (typeof arg2 === 'string' ? arg2 : void 0);
|
||||
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);
|
||||
if (typeof section === 'undefined') {
|
||||
return this.configurationService.getValue<T>();
|
||||
}
|
||||
return this.configurationService.getValue<T>(section);
|
||||
}
|
||||
}
|
||||
|
||||
export class SimpleMenuService implements IMenuService {
|
||||
export class SimpleResourcePropertiesService implements ITextResourcePropertiesService {
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private readonly _commandService: ICommandService;
|
||||
|
||||
constructor(commandService: ICommandService) {
|
||||
this._commandService = commandService;
|
||||
constructor(
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
) {
|
||||
}
|
||||
|
||||
public createMenu(id: MenuId, contextKeyService: IContextKeyService): IMenu {
|
||||
return new Menu(id, TPromise.as(true), this._commandService, contextKeyService);
|
||||
getEOL(resource: URI): string {
|
||||
const filesConfiguration = this.configurationService.getValue<{ eol: string }>('files');
|
||||
if (filesConfiguration && filesConfiguration.eol) {
|
||||
if (filesConfiguration.eol !== 'auto') {
|
||||
return filesConfiguration.eol;
|
||||
}
|
||||
}
|
||||
return (isLinux || isMacintosh) ? '\n' : '\r\n';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,12 +487,12 @@ export class StandaloneTelemetryService implements ITelemetryService {
|
||||
|
||||
public isOptedIn = false;
|
||||
|
||||
public publicLog(eventName: string, data?: any): TPromise<void> {
|
||||
return TPromise.wrap<void>(null);
|
||||
public publicLog(eventName: string, data?: any): Promise<void> {
|
||||
return Promise.resolve(void 0);
|
||||
}
|
||||
|
||||
public getTelemetryInfo(): TPromise<ITelemetryInfo> {
|
||||
return null;
|
||||
public getTelemetryInfo(): Promise<ITelemetryInfo> {
|
||||
throw new Error(`Not available`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,7 +500,7 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService {
|
||||
|
||||
public _serviceBrand: any;
|
||||
|
||||
private static SCHEME: 'inmemory';
|
||||
private static SCHEME = 'inmemory';
|
||||
|
||||
private readonly _onDidChangeWorkspaceName: Emitter<void> = new Emitter<void>();
|
||||
public readonly onDidChangeWorkspaceName: Event<void> = this._onDidChangeWorkspaceName.event;
|
||||
@@ -503,7 +515,7 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService {
|
||||
|
||||
constructor() {
|
||||
const resource = URI.from({ scheme: SimpleWorkspaceContextService.SCHEME, authority: 'model', path: '/' });
|
||||
this.workspace = { id: '4064f6ec-cb38-4ad0-af64-ee6467e63c82', folders: [new WorkspaceFolder({ uri: resource, name: '', index: 0 })], name: resource.fsPath };
|
||||
this.workspace = { id: '4064f6ec-cb38-4ad0-af64-ee6467e63c82', folders: [new WorkspaceFolder({ uri: resource, name: '', index: 0 })] };
|
||||
}
|
||||
|
||||
public getWorkspace(): IWorkspace {
|
||||
@@ -520,8 +532,8 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService {
|
||||
return WorkbenchState.EMPTY;
|
||||
}
|
||||
|
||||
public getWorkspaceFolder(resource: URI): IWorkspaceFolder {
|
||||
return resource && resource.scheme === SimpleWorkspaceContextService.SCHEME ? this.workspace.folders[0] : void 0;
|
||||
public getWorkspaceFolder(resource: URI): IWorkspaceFolder | null {
|
||||
return resource && resource.scheme === SimpleWorkspaceContextService.SCHEME ? this.workspace.folders[0] : null;
|
||||
}
|
||||
|
||||
public isInsideWorkspace(resource: URI): boolean {
|
||||
@@ -557,23 +569,25 @@ export class SimpleBulkEditService implements IBulkEditService {
|
||||
//
|
||||
}
|
||||
|
||||
apply(workspaceEdit: WorkspaceEdit, options: IBulkEditOptions): TPromise<IBulkEditResult> {
|
||||
apply(workspaceEdit: WorkspaceEdit, options: IBulkEditOptions): Promise<IBulkEditResult> {
|
||||
|
||||
let edits = new Map<ITextModel, TextEdit[]>();
|
||||
|
||||
for (let edit of workspaceEdit.edits) {
|
||||
if (!isResourceTextEdit(edit)) {
|
||||
return TPromise.wrapError(new Error('bad edit - only text edits are supported'));
|
||||
if (workspaceEdit.edits) {
|
||||
for (let edit of workspaceEdit.edits) {
|
||||
if (!isResourceTextEdit(edit)) {
|
||||
return Promise.reject(new Error('bad edit - only text edits are supported'));
|
||||
}
|
||||
let model = this._modelService.getModel(edit.resource);
|
||||
if (!model) {
|
||||
return Promise.reject(new Error('bad edit - model not found'));
|
||||
}
|
||||
let array = edits.get(model);
|
||||
if (!array) {
|
||||
array = [];
|
||||
}
|
||||
edits.set(model, array.concat(edit.edits));
|
||||
}
|
||||
let model = this._modelService.getModel(edit.resource);
|
||||
if (!model) {
|
||||
return TPromise.wrapError(new Error('bad edit - model not found'));
|
||||
}
|
||||
let array = edits.get(model);
|
||||
if (!array) {
|
||||
array = [];
|
||||
}
|
||||
edits.set(model, array.concat(edit.edits));
|
||||
}
|
||||
|
||||
let totalEdits = 0;
|
||||
@@ -584,9 +598,35 @@ export class SimpleBulkEditService implements IBulkEditService {
|
||||
totalEdits += edits.length;
|
||||
});
|
||||
|
||||
return TPromise.as({
|
||||
return Promise.resolve({
|
||||
selection: undefined,
|
||||
ariaSummary: localize('summary', 'Made {0} edits in {1} files', totalEdits, totalFiles)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class SimpleUriLabelService implements ILabelService {
|
||||
_serviceBrand: any;
|
||||
|
||||
private readonly _onDidRegisterFormatter: Emitter<RegisterFormatterEvent> = new Emitter<RegisterFormatterEvent>();
|
||||
public readonly onDidRegisterFormatter: Event<RegisterFormatterEvent> = this._onDidRegisterFormatter.event;
|
||||
|
||||
public getUriLabel(resource: URI, options?: { relative?: boolean, forceNoTildify?: boolean }): string {
|
||||
if (resource.scheme === 'file') {
|
||||
return resource.fsPath;
|
||||
}
|
||||
return resource.path;
|
||||
}
|
||||
|
||||
public getWorkspaceLabel(workspace: IWorkspaceIdentifier | URI | IWorkspace, options?: { verbose: boolean; }): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
public registerFormatter(selector: string, formatter: LabelRules): IDisposable {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
||||
public getHostLabel(): string {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,17 +9,13 @@
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "HelveticaNeue-Light", "Ubuntu", "Droid Sans", sans-serif;
|
||||
}
|
||||
|
||||
.monaco-menu .monaco-action-bar.vertical .action-item .action-label:focus {
|
||||
color: #0059AC;
|
||||
.monaco-menu .monaco-action-bar.vertical .action-item .action-menu-item:focus .action-label {
|
||||
stroke-width: 1.2px;
|
||||
text-shadow: 0px 0px 0.15px #0059AC;
|
||||
}
|
||||
|
||||
.monaco-editor.vs-dark .monaco-menu .monaco-action-bar.vertical .action-item .action-label:focus,
|
||||
.monaco-editor.hc-black .monaco-menu .monaco-action-bar.vertical .action-item .action-label:focus {
|
||||
color: #ACDDFF;
|
||||
.monaco-editor.vs-dark .monaco-menu .monaco-action-bar.vertical .action-menu-item:focus .action-label,
|
||||
.monaco-editor.hc-black .monaco-menu .monaco-action-bar.vertical .action-menu-item:focus .action-label {
|
||||
stroke-width: 1.2px;
|
||||
text-shadow: 0px 0px 0.15px #ACDDFF;
|
||||
}
|
||||
|
||||
.monaco-editor-hover p {
|
||||
@@ -211,14 +207,14 @@
|
||||
}
|
||||
|
||||
/* contextmenu */
|
||||
.monaco-editor.vs .monaco-menu .monaco-action-bar.vertical .action-item .action-label:focus,
|
||||
.monaco-editor.vs-dark .monaco-menu .monaco-action-bar.vertical .action-item .action-label:focus {
|
||||
.monaco-editor.vs .monaco-menu .monaco-action-bar.vertical .action-menu-item:focus .action-label,
|
||||
.monaco-editor.vs-dark .monaco-menu .monaco-action-bar.vertical .action-menu-item:focus .action-label {
|
||||
-ms-high-contrast-adjust: none;
|
||||
color: highlighttext !important;
|
||||
background-color: highlight !important;
|
||||
}
|
||||
.monaco-editor.vs .monaco-menu .monaco-action-bar.vertical .action-item .action-label:hover,
|
||||
.monaco-editor.vs-dark .monaco-menu .monaco-action-bar.vertical .action-item .action-label:hover {
|
||||
.monaco-editor.vs .monaco-menu .monaco-action-bar.vertical .action-menu-item:hover .action-label,
|
||||
.monaco-editor.vs-dark .monaco-menu .monaco-action-bar.vertical .action-menu-item:hover .action-label {
|
||||
-ms-high-contrast-adjust: none;
|
||||
background: transparent !important;
|
||||
border: 1px solid highlight;
|
||||
|
||||
@@ -3,34 +3,31 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { Disposable, IDisposable, combinedDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { CommandsRegistry, ICommandService, ICommandHandler } from 'vs/platform/commands/common/commands';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ContextKeyExpr, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IModelChangedEvent } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { StandaloneKeybindingService, applyConfigurationValues } from 'vs/editor/standalone/browser/simpleServices';
|
||||
import { ContextViewService } from 'vs/platform/contextview/browser/contextViewService';
|
||||
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
|
||||
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
|
||||
import { ICodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { InternalEditorAction } from 'vs/editor/common/editorAction';
|
||||
import { MenuId, MenuRegistry, IMenuItem } from 'vs/platform/actions/common/actions';
|
||||
import { IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import * as aria from 'vs/base/browser/ui/aria/aria';
|
||||
import * as nls from 'vs/nls';
|
||||
import * as browser from 'vs/base/browser/browser';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import * as aria from 'vs/base/browser/ui/aria/aria';
|
||||
import { Disposable, IDisposable, combinedDisposable, toDisposable } 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';
|
||||
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
|
||||
import { IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/editorOptions';
|
||||
import { InternalEditorAction } from 'vs/editor/common/editorAction';
|
||||
import { IModelChangedEvent } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { StandaloneKeybindingService, applyConfigurationValues } from 'vs/editor/standalone/browser/simpleServices';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { IMenuItem, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import { CommandsRegistry, ICommandHandler, ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ContextKeyExpr, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { ContextViewService } from 'vs/platform/contextview/browser/contextViewService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
/**
|
||||
* Description of an action contribution
|
||||
@@ -72,9 +69,9 @@ export interface IActionDescriptor {
|
||||
contextMenuOrder?: number;
|
||||
/**
|
||||
* Method that will be executed when the action is triggered.
|
||||
* @param editor The editor instance is passed in as a convinience
|
||||
* @param editor The editor instance is passed in as a convenience
|
||||
*/
|
||||
run(editor: ICodeEditor): void | TPromise<void>;
|
||||
run(editor: ICodeEditor): void | Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +81,7 @@ export interface IEditorConstructionOptions extends IEditorOptions {
|
||||
/**
|
||||
* The initial model associated with this code editor.
|
||||
*/
|
||||
model?: ITextModel;
|
||||
model?: ITextModel | null;
|
||||
/**
|
||||
* The initial value of the auto created model in the editor.
|
||||
* To not create automatically a model, use `model: null`.
|
||||
@@ -125,13 +122,13 @@ export interface IDiffEditorConstructionOptions extends IDiffEditorOptions {
|
||||
}
|
||||
|
||||
export interface IStandaloneCodeEditor extends ICodeEditor {
|
||||
addCommand(keybinding: number, handler: ICommandHandler, context: string): string;
|
||||
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;
|
||||
addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null;
|
||||
createContextKey<T>(key: string, defaultValue: T): IContextKey<T>;
|
||||
addAction(descriptor: IActionDescriptor): IDisposable;
|
||||
|
||||
@@ -185,7 +182,7 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
|
||||
createAriaDomNode();
|
||||
}
|
||||
|
||||
public addCommand(keybinding: number, handler: ICommandHandler, context: string): string {
|
||||
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;
|
||||
@@ -223,9 +220,8 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
|
||||
);
|
||||
const contextMenuGroupId = _descriptor.contextMenuGroupId || null;
|
||||
const contextMenuOrder = _descriptor.contextMenuOrder || 0;
|
||||
const run = (): TPromise<void> => {
|
||||
const r = _descriptor.run(this);
|
||||
return r ? r : TPromise.as(void 0);
|
||||
const run = (): Promise<void> => {
|
||||
return Promise.resolve(_descriptor.run(this));
|
||||
};
|
||||
|
||||
|
||||
@@ -288,7 +284,7 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
|
||||
|
||||
constructor(
|
||||
domElement: HTMLElement,
|
||||
options: IEditorConstructionOptions,
|
||||
options: IEditorConstructionOptions | undefined,
|
||||
toDispose: IDisposable,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@ICodeEditorService codeEditorService: ICodeEditorService,
|
||||
@@ -305,7 +301,7 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
|
||||
if (typeof options.theme === 'string') {
|
||||
themeService.setTheme(options.theme);
|
||||
}
|
||||
let model: ITextModel = options.model;
|
||||
let _model: ITextModel | null | undefined = options.model;
|
||||
delete options.model;
|
||||
super(domElement, options, instantiationService, codeEditorService, commandService, contextKeyService, keybindingService, themeService, notificationService);
|
||||
|
||||
@@ -313,10 +309,12 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
|
||||
this._configurationService = configurationService;
|
||||
this._register(toDispose);
|
||||
|
||||
if (typeof model === 'undefined') {
|
||||
let model: ITextModel | null;
|
||||
if (typeof _model === 'undefined') {
|
||||
model = (<any>self).monaco.editor.createModel(options.value || '', options.language || 'text/plain');
|
||||
this._ownsModel = true;
|
||||
} else {
|
||||
model = _model;
|
||||
this._ownsModel = false;
|
||||
}
|
||||
|
||||
@@ -339,10 +337,10 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
|
||||
super.updateOptions(newOptions);
|
||||
}
|
||||
|
||||
_attachModel(model: ITextModel): void {
|
||||
_attachModel(model: ITextModel | null): void {
|
||||
super._attachModel(model);
|
||||
if (this._view) {
|
||||
this._contextViewService.setContainer(this._view.domNode.domNode);
|
||||
if (this._modelData) {
|
||||
this._contextViewService.setContainer(this._modelData.view.domNode.domNode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +409,7 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
|
||||
return <StandaloneCodeEditor>super.getModifiedEditor();
|
||||
}
|
||||
|
||||
public addCommand(keybinding: number, handler: ICommandHandler, context: string): string {
|
||||
public addCommand(keybinding: number, handler: ICommandHandler, context: string): string | null {
|
||||
return this.getModifiedEditor().addCommand(keybinding, handler, context);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,34 +2,32 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { IResourceInput } from 'vs/platform/editor/common/editor';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { CodeEditorServiceImpl } from 'vs/editor/browser/services/codeEditorServiceImpl';
|
||||
import { ScrollType } from 'vs/editor/common/editorCommon';
|
||||
import { windowOpenNoOpener } from 'vs/base/browser/dom';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { CodeEditorServiceImpl } from 'vs/editor/browser/services/codeEditorServiceImpl';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import { ScrollType } from 'vs/editor/common/editorCommon';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { IResourceInput } from 'vs/platform/editor/common/editor';
|
||||
|
||||
export class StandaloneCodeEditorServiceImpl extends CodeEditorServiceImpl {
|
||||
|
||||
public getActiveCodeEditor(): ICodeEditor {
|
||||
public getActiveCodeEditor(): ICodeEditor | null {
|
||||
return null; // not supported in the standalone case
|
||||
}
|
||||
|
||||
public openCodeEditor(input: IResourceInput, source: ICodeEditor, sideBySide?: boolean): TPromise<ICodeEditor> {
|
||||
public openCodeEditor(input: IResourceInput, source: ICodeEditor | null, sideBySide?: boolean): Thenable<ICodeEditor | null> {
|
||||
if (!source) {
|
||||
return TPromise.as(null);
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
return TPromise.as(this.doOpenEditor(source, input));
|
||||
return Promise.resolve(this.doOpenEditor(source, input));
|
||||
}
|
||||
|
||||
private doOpenEditor(editor: ICodeEditor, input: IResourceInput): ICodeEditor {
|
||||
private doOpenEditor(editor: ICodeEditor, input: IResourceInput): ICodeEditor | null {
|
||||
const model = this.findModel(editor, input.resource);
|
||||
if (!model) {
|
||||
if (input.resource) {
|
||||
@@ -44,7 +42,7 @@ export class StandaloneCodeEditorServiceImpl extends CodeEditorServiceImpl {
|
||||
return null;
|
||||
}
|
||||
|
||||
const selection = <IRange>input.options.selection;
|
||||
const selection = <IRange>(input.options ? input.options.selection : null);
|
||||
if (selection) {
|
||||
if (typeof selection.endLineNumber === 'number' && typeof selection.endColumn === 'number') {
|
||||
editor.setSelection(selection);
|
||||
@@ -62,9 +60,9 @@ export class StandaloneCodeEditorServiceImpl extends CodeEditorServiceImpl {
|
||||
return editor;
|
||||
}
|
||||
|
||||
private findModel(editor: ICodeEditor, resource: URI): ITextModel {
|
||||
private findModel(editor: ICodeEditor, resource: URI): ITextModel | null {
|
||||
const model = editor.getModel();
|
||||
if (model.uri.toString() !== resource.toString()) {
|
||||
if (model && model.uri.toString() !== resource.toString()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,47 +2,45 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import 'vs/css!./standalone-tokens';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { ICodeEditor, ContentWidgetPositionPreference, OverlayWidgetPositionPreference, MouseTargetType } from 'vs/editor/browser/editorBrowser';
|
||||
import { StandaloneEditor, IStandaloneCodeEditor, StandaloneDiffEditor, IStandaloneDiffEditor, IEditorConstructionOptions, IDiffEditorConstructionOptions } from 'vs/editor/standalone/browser/standaloneCodeEditor';
|
||||
import { ScrollbarVisibility } from 'vs/base/common/scrollable';
|
||||
import { IEditorOverrideServices, DynamicStandaloneServices, StaticServices } from 'vs/editor/standalone/browser/standaloneServices';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { OpenerService } from 'vs/editor/browser/services/openerService';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { DiffNavigator } from 'vs/editor/browser/widget/diffNavigator';
|
||||
import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { BareFontInfo, FontInfo } from 'vs/editor/common/config/fontInfo';
|
||||
import { Token } from 'vs/editor/common/core/token';
|
||||
import * as editorCommon from 'vs/editor/common/editorCommon';
|
||||
import { FindMatch, ITextModel, TextModelResolvedOptions } from 'vs/editor/common/model';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { NULL_STATE, nullTokenize } from 'vs/editor/common/modes/nullMode';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { ILanguageSelection } from 'vs/editor/common/services/modeService';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { IWebWorkerOptions, MonacoWebWorker, createWebWorker as actualCreateWebWorker } from 'vs/editor/common/services/webWorker';
|
||||
import * as standaloneEnums from 'vs/editor/common/standalone/standaloneEnums';
|
||||
import { Colorizer, IColorizerElementOptions, IColorizerOptions } from 'vs/editor/standalone/browser/colorizer';
|
||||
import { SimpleEditorModelResolverService } from 'vs/editor/standalone/browser/simpleServices';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { IWebWorkerOptions, MonacoWebWorker, createWebWorker as actualCreateWebWorker } from 'vs/editor/common/services/webWorker';
|
||||
import { IMarkerData, IMarker } from 'vs/platform/markers/common/markers';
|
||||
import { DiffNavigator } from 'vs/editor/browser/widget/diffNavigator';
|
||||
import { IDiffEditorConstructionOptions, IEditorConstructionOptions, IStandaloneCodeEditor, IStandaloneDiffEditor, StandaloneDiffEditor, StandaloneEditor } from 'vs/editor/standalone/browser/standaloneCodeEditor';
|
||||
import { DynamicStandaloneServices, IEditorOverrideServices, StaticServices } from 'vs/editor/standalone/browser/standaloneServices';
|
||||
import { IStandaloneThemeData, IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { NULL_STATE, nullTokenize } from 'vs/editor/common/modes/nullMode';
|
||||
import { IStandaloneThemeData, IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { Token } from 'vs/editor/common/core/token';
|
||||
import { FontInfo, BareFontInfo } from 'vs/editor/common/config/fontInfo';
|
||||
import * as editorOptions from 'vs/editor/common/config/editorOptions';
|
||||
import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents';
|
||||
import { ITextModel, OverviewRulerLane, EndOfLinePreference, DefaultEndOfLine, EndOfLineSequence, TrackedRangeStickiness, TextModelResolvedOptions, FindMatch } from 'vs/editor/common/model';
|
||||
import { IMarker, IMarkerData } from 'vs/platform/markers/common/markers';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
|
||||
function withAllStandaloneServices<T extends editorCommon.IEditor>(domElement: HTMLElement, override: IEditorOverrideServices, callback: (services: DynamicStandaloneServices) => T): T {
|
||||
let services = new DynamicStandaloneServices(domElement, override);
|
||||
|
||||
let simpleEditorModelResolverService: SimpleEditorModelResolverService = null;
|
||||
let simpleEditorModelResolverService: SimpleEditorModelResolverService | null = null;
|
||||
if (!services.has(ITextModelService)) {
|
||||
simpleEditorModelResolverService = new SimpleEditorModelResolverService();
|
||||
services.set(ITextModelService, simpleEditorModelResolverService);
|
||||
@@ -67,7 +65,7 @@ function withAllStandaloneServices<T extends editorCommon.IEditor>(domElement: H
|
||||
* The editor will read the size of `domElement`.
|
||||
*/
|
||||
export function create(domElement: HTMLElement, options?: IEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneCodeEditor {
|
||||
return withAllStandaloneServices(domElement, override, (services) => {
|
||||
return withAllStandaloneServices(domElement, override || {}, (services) => {
|
||||
return new StandaloneEditor(
|
||||
domElement,
|
||||
options,
|
||||
@@ -137,8 +135,8 @@ export function createDiffNavigator(diffEditor: IStandaloneDiffEditor, opts?: ID
|
||||
return new DiffNavigator(diffEditor, opts);
|
||||
}
|
||||
|
||||
function doCreateModel(value: string, mode: TPromise<modes.IMode>, uri?: URI): ITextModel {
|
||||
return StaticServices.modelService.get().createModel(value, mode, uri);
|
||||
function doCreateModel(value: string, languageSelection: ILanguageSelection, uri?: URI): ITextModel {
|
||||
return StaticServices.modelService.get().createModel(value, languageSelection, uri);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,16 +155,16 @@ export function createModel(value: string, language?: string, uri?: URI): ITextM
|
||||
firstLine = value.substring(0, firstLF);
|
||||
}
|
||||
|
||||
return doCreateModel(value, StaticServices.modeService.get().getOrCreateModeByFilenameOrFirstLine(path, firstLine), uri);
|
||||
return doCreateModel(value, StaticServices.modeService.get().createByFilepathOrFirstLine(path, firstLine), uri);
|
||||
}
|
||||
return doCreateModel(value, StaticServices.modeService.get().getOrCreateMode(language), uri);
|
||||
return doCreateModel(value, StaticServices.modeService.get().create(language), uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the language for a model.
|
||||
*/
|
||||
export function setModelLanguage(model: ITextModel, languageId: string): void {
|
||||
StaticServices.modelService.get().setMode(model, StaticServices.modeService.get().getOrCreateMode(languageId));
|
||||
StaticServices.modelService.get().setMode(model, StaticServices.modeService.get().create(languageId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -190,7 +188,7 @@ export function getModelMarkers(filter: { owner?: string, resource?: URI, take?:
|
||||
/**
|
||||
* Get the model that has `uri` if it exists.
|
||||
*/
|
||||
export function getModel(uri: URI): ITextModel {
|
||||
export function getModel(uri: URI): ITextModel | null {
|
||||
return StaticServices.modelService.get().getModel(uri);
|
||||
}
|
||||
|
||||
@@ -241,14 +239,14 @@ export function createWebWorker<T>(opts: IWebWorkerOptions): MonacoWebWorker<T>
|
||||
/**
|
||||
* Colorize the contents of `domNode` using attribute `data-lang`.
|
||||
*/
|
||||
export function colorizeElement(domNode: HTMLElement, options: IColorizerElementOptions): TPromise<void> {
|
||||
export function colorizeElement(domNode: HTMLElement, options: IColorizerElementOptions): Promise<void> {
|
||||
return Colorizer.colorizeElement(StaticServices.standaloneThemeService.get(), StaticServices.modeService.get(), domNode, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Colorize `text` using language `languageId`.
|
||||
*/
|
||||
export function colorize(text: string, languageId: string, options: IColorizerOptions): TPromise<string> {
|
||||
export function colorize(text: string, languageId: string, options: IColorizerOptions): Promise<string> {
|
||||
return Colorizer.colorize(StaticServices.modeService.get(), text, languageId, options);
|
||||
}
|
||||
|
||||
@@ -280,7 +278,7 @@ function getSafeTokenizationSupport(language: string): modes.ITokenizationSuppor
|
||||
export function tokenize(text: string, languageId: string): Token[][] {
|
||||
let modeService = StaticServices.modeService.get();
|
||||
// Needed in order to get the mode registered for subsequent look-ups
|
||||
modeService.getOrCreateMode(languageId);
|
||||
modeService.triggerMode(languageId);
|
||||
|
||||
let tokenizationSupport = getSafeTokenizationSupport(languageId);
|
||||
let lines = text.split(/\r\n|\r|\n/);
|
||||
@@ -297,7 +295,7 @@ export function tokenize(text: string, languageId: string): Token[][] {
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a new theme or updte an existing theme.
|
||||
* Define a new theme or update an existing theme.
|
||||
*/
|
||||
export function defineTheme(themeName: string, themeData: IStandaloneThemeData): void {
|
||||
StaticServices.standaloneThemeService.get().defineTheme(themeName, themeData);
|
||||
@@ -310,33 +308,6 @@ export function setTheme(themeName: string): void {
|
||||
StaticServices.standaloneThemeService.get().setTheme(themeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* --------------------------------------------
|
||||
* This is repeated here so it can be exported
|
||||
* because TS inlines const enums
|
||||
* --------------------------------------------
|
||||
*/
|
||||
enum ScrollType {
|
||||
Smooth = 0,
|
||||
Immediate = 1,
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* --------------------------------------------
|
||||
* This is repeated here so it can be exported
|
||||
* because TS inlines const enums
|
||||
* --------------------------------------------
|
||||
*/
|
||||
enum RenderLineNumbersType {
|
||||
Off = 0,
|
||||
On = 1,
|
||||
Relative = 2,
|
||||
Interval = 3,
|
||||
Custom = 4
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@@ -348,42 +319,42 @@ export function createMonacoEditorAPI(): typeof monaco.editor {
|
||||
createDiffEditor: <any>createDiffEditor,
|
||||
createDiffNavigator: <any>createDiffNavigator,
|
||||
|
||||
createModel: createModel,
|
||||
setModelLanguage: setModelLanguage,
|
||||
setModelMarkers: setModelMarkers,
|
||||
getModelMarkers: getModelMarkers,
|
||||
getModels: getModels,
|
||||
getModel: getModel,
|
||||
onDidCreateModel: onDidCreateModel,
|
||||
onWillDisposeModel: onWillDisposeModel,
|
||||
onDidChangeModelLanguage: onDidChangeModelLanguage,
|
||||
createModel: <any>createModel,
|
||||
setModelLanguage: <any>setModelLanguage,
|
||||
setModelMarkers: <any>setModelMarkers,
|
||||
getModelMarkers: <any>getModelMarkers,
|
||||
getModels: <any>getModels,
|
||||
getModel: <any>getModel,
|
||||
onDidCreateModel: <any>onDidCreateModel,
|
||||
onWillDisposeModel: <any>onWillDisposeModel,
|
||||
onDidChangeModelLanguage: <any>onDidChangeModelLanguage,
|
||||
|
||||
|
||||
createWebWorker: createWebWorker,
|
||||
colorizeElement: colorizeElement,
|
||||
colorize: colorize,
|
||||
colorizeModelLine: colorizeModelLine,
|
||||
tokenize: tokenize,
|
||||
defineTheme: defineTheme,
|
||||
setTheme: setTheme,
|
||||
createWebWorker: <any>createWebWorker,
|
||||
colorizeElement: <any>colorizeElement,
|
||||
colorize: <any>colorize,
|
||||
colorizeModelLine: <any>colorizeModelLine,
|
||||
tokenize: <any>tokenize,
|
||||
defineTheme: <any>defineTheme,
|
||||
setTheme: <any>setTheme,
|
||||
|
||||
// enums
|
||||
ScrollbarVisibility: ScrollbarVisibility,
|
||||
WrappingIndent: editorOptions.WrappingIndent,
|
||||
OverviewRulerLane: OverviewRulerLane,
|
||||
EndOfLinePreference: EndOfLinePreference,
|
||||
DefaultEndOfLine: DefaultEndOfLine,
|
||||
EndOfLineSequence: EndOfLineSequence,
|
||||
TrackedRangeStickiness: TrackedRangeStickiness,
|
||||
CursorChangeReason: CursorChangeReason,
|
||||
MouseTargetType: MouseTargetType,
|
||||
TextEditorCursorStyle: editorOptions.TextEditorCursorStyle,
|
||||
TextEditorCursorBlinkingStyle: editorOptions.TextEditorCursorBlinkingStyle,
|
||||
ContentWidgetPositionPreference: ContentWidgetPositionPreference,
|
||||
OverlayWidgetPositionPreference: OverlayWidgetPositionPreference,
|
||||
RenderMinimap: editorOptions.RenderMinimap,
|
||||
ScrollType: <any>ScrollType,
|
||||
RenderLineNumbersType: <any>RenderLineNumbersType,
|
||||
ScrollbarVisibility: standaloneEnums.ScrollbarVisibility,
|
||||
WrappingIndent: standaloneEnums.WrappingIndent,
|
||||
OverviewRulerLane: standaloneEnums.OverviewRulerLane,
|
||||
EndOfLinePreference: standaloneEnums.EndOfLinePreference,
|
||||
DefaultEndOfLine: standaloneEnums.DefaultEndOfLine,
|
||||
EndOfLineSequence: standaloneEnums.EndOfLineSequence,
|
||||
TrackedRangeStickiness: standaloneEnums.TrackedRangeStickiness,
|
||||
CursorChangeReason: standaloneEnums.CursorChangeReason,
|
||||
MouseTargetType: standaloneEnums.MouseTargetType,
|
||||
TextEditorCursorStyle: standaloneEnums.TextEditorCursorStyle,
|
||||
TextEditorCursorBlinkingStyle: standaloneEnums.TextEditorCursorBlinkingStyle,
|
||||
ContentWidgetPositionPreference: standaloneEnums.ContentWidgetPositionPreference,
|
||||
OverlayWidgetPositionPreference: standaloneEnums.OverlayWidgetPositionPreference,
|
||||
RenderMinimap: standaloneEnums.RenderMinimap,
|
||||
ScrollType: standaloneEnums.ScrollType,
|
||||
RenderLineNumbersType: standaloneEnums.RenderLineNumbersType,
|
||||
|
||||
// classes
|
||||
InternalEditorOptions: <any>editorOptions.InternalEditorOptions,
|
||||
|
||||
@@ -3,28 +3,24 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { ModesRegistry } from 'vs/editor/common/modes/modesRegistry';
|
||||
import { IMonarchLanguage } from 'vs/editor/standalone/common/monarch/monarchTypes';
|
||||
import { ILanguageExtensionPoint } from 'vs/editor/common/services/modeService';
|
||||
import { StaticServices } from 'vs/editor/standalone/browser/standaloneServices';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { LanguageConfiguration, IndentAction } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { toThenable } from 'vs/base/common/async';
|
||||
import { Token, TokenizationResult, TokenizationResult2 } from 'vs/editor/common/core/token';
|
||||
import * as model from 'vs/editor/common/model';
|
||||
import * as modes from 'vs/editor/common/modes';
|
||||
import { LanguageConfiguration } from 'vs/editor/common/modes/languageConfiguration';
|
||||
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import { ModesRegistry } from 'vs/editor/common/modes/modesRegistry';
|
||||
import { ILanguageExtensionPoint } from 'vs/editor/common/services/modeService';
|
||||
import * as standaloneEnums from 'vs/editor/common/standalone/standaloneEnums';
|
||||
import { StaticServices } from 'vs/editor/standalone/browser/standaloneServices';
|
||||
import { compile } from 'vs/editor/standalone/common/monarch/monarchCompile';
|
||||
import { createTokenizationSupport } from 'vs/editor/standalone/common/monarch/monarchLexer';
|
||||
import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry';
|
||||
import { IMarkerData } from 'vs/platform/markers/common/markers';
|
||||
import { Token, TokenizationResult, TokenizationResult2 } from 'vs/editor/common/core/token';
|
||||
import { IMonarchLanguage } from 'vs/editor/standalone/common/monarch/monarchTypes';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import * as model from 'vs/editor/common/model';
|
||||
import { IMarkdownString } from 'vs/base/common/htmlContent';
|
||||
import { IMarkerData } from 'vs/platform/markers/common/markers';
|
||||
|
||||
/**
|
||||
* Register information about a new language.
|
||||
@@ -44,7 +40,7 @@ export function getLanguages(): ILanguageExtensionPoint[] {
|
||||
|
||||
export function getEncodedLanguageId(languageId: string): number {
|
||||
let lid = StaticServices.modeService.get().getLanguageIdentifier(languageId);
|
||||
return lid && lid.id;
|
||||
return lid ? lid.id : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -338,7 +334,7 @@ export function registerRenameProvider(languageId: string, provider: modes.Renam
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a signature help provider (used by e.g. paremeter hints).
|
||||
* Register a signature help provider (used by e.g. parameter hints).
|
||||
*/
|
||||
export function registerSignatureHelpProvider(languageId: string, provider: modes.SignatureHelpProvider): IDisposable {
|
||||
return modes.SignatureHelpProviderRegistry.register(languageId, provider);
|
||||
@@ -352,7 +348,7 @@ export function registerHoverProvider(languageId: string, provider: modes.HoverP
|
||||
provideHover: (model: model.ITextModel, position: Position, token: CancellationToken): Thenable<modes.Hover> => {
|
||||
let word = model.getWordAtPosition(position);
|
||||
|
||||
return toThenable<modes.Hover>(provider.provideHover(model, position, token)).then((value) => {
|
||||
return Promise.resolve<modes.Hover | null | undefined>(provider.provideHover(model, position, token)).then((value) => {
|
||||
if (!value) {
|
||||
return undefined;
|
||||
}
|
||||
@@ -455,17 +451,8 @@ export function registerLinkProvider(languageId: string, provider: modes.LinkPro
|
||||
/**
|
||||
* Register a completion item provider (use by e.g. suggestions).
|
||||
*/
|
||||
export function registerCompletionItemProvider(languageId: string, provider: CompletionItemProvider): IDisposable {
|
||||
let adapter = new SuggestAdapter(provider);
|
||||
return modes.SuggestRegistry.register(languageId, {
|
||||
triggerCharacters: provider.triggerCharacters,
|
||||
provideCompletionItems: (model: model.ITextModel, position: Position, context: modes.SuggestContext, token: CancellationToken): Thenable<modes.ISuggestResult> => {
|
||||
return adapter.provideCompletionItems(model, position, context, token);
|
||||
},
|
||||
resolveCompletionItem: (model: model.ITextModel, position: Position, suggestion: modes.ISuggestion, token: CancellationToken): Thenable<modes.ISuggestion> => {
|
||||
return adapter.resolveCompletionItem(model, position, suggestion, token);
|
||||
}
|
||||
});
|
||||
export function registerCompletionItemProvider(languageId: string, provider: modes.CompletionItemProvider): IDisposable {
|
||||
return modes.CompletionProviderRegistry.register(languageId, provider);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -512,375 +499,49 @@ export interface CodeActionProvider {
|
||||
provideCodeActions(model: model.ITextModel, range: Range, context: CodeActionContext, token: CancellationToken): (modes.Command | modes.CodeAction)[] | Thenable<(modes.Command | modes.CodeAction)[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Completion item kinds.
|
||||
*/
|
||||
export enum CompletionItemKind {
|
||||
Text,
|
||||
Method,
|
||||
Function,
|
||||
Constructor,
|
||||
Field,
|
||||
Variable,
|
||||
Class,
|
||||
Interface,
|
||||
Module,
|
||||
Property,
|
||||
Unit,
|
||||
Value,
|
||||
Enum,
|
||||
Keyword,
|
||||
Snippet,
|
||||
Color,
|
||||
File,
|
||||
Reference,
|
||||
Folder
|
||||
}
|
||||
|
||||
/**
|
||||
* A snippet string is a template which allows to insert text
|
||||
* and to control the editor cursor when insertion happens.
|
||||
*
|
||||
* A snippet can define tab stops and placeholders with `$1`, `$2`
|
||||
* and `${3:foo}`. `$0` defines the final tab stop, it defaults to
|
||||
* the end of the snippet. Variables are defined with `$name` and
|
||||
* `${name:default value}`. The full snippet syntax is documented
|
||||
* [here](http://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets).
|
||||
*/
|
||||
export interface SnippetString {
|
||||
|
||||
/**
|
||||
* The snippet string.
|
||||
*/
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A completion item represents a text snippet that is
|
||||
* proposed to complete text that is being typed.
|
||||
*/
|
||||
export interface CompletionItem {
|
||||
/**
|
||||
* The label of this completion item. By default
|
||||
* this is also the text that is inserted when selecting
|
||||
* this completion.
|
||||
*/
|
||||
label: string;
|
||||
/**
|
||||
* The kind of this completion item. Based on the kind
|
||||
* an icon is chosen by the editor.
|
||||
*/
|
||||
kind: CompletionItemKind;
|
||||
/**
|
||||
* A human-readable string with additional information
|
||||
* about this item, like type or symbol information.
|
||||
*/
|
||||
detail?: string;
|
||||
/**
|
||||
* A human-readable string that represents a doc-comment.
|
||||
*/
|
||||
documentation?: string | IMarkdownString;
|
||||
/**
|
||||
* A command that should be run upon acceptance of this item.
|
||||
*/
|
||||
command?: modes.Command;
|
||||
/**
|
||||
* A string that should be used when comparing this item
|
||||
* with other items. When `falsy` the [label](#CompletionItem.label)
|
||||
* is used.
|
||||
*/
|
||||
sortText?: string;
|
||||
/**
|
||||
* A string that should be used when filtering a set of
|
||||
* completion items. When `falsy` the [label](#CompletionItem.label)
|
||||
* is used.
|
||||
*/
|
||||
filterText?: string;
|
||||
/**
|
||||
* A string or snippet that should be inserted in a document when selecting
|
||||
* this completion. When `falsy` the [label](#CompletionItem.label)
|
||||
* is used.
|
||||
*/
|
||||
insertText?: string | SnippetString;
|
||||
/**
|
||||
* A range of text that should be replaced by this completion item.
|
||||
*
|
||||
* Defaults to a range from the start of the [current word](#TextDocument.getWordRangeAtPosition) to the
|
||||
* current position.
|
||||
*
|
||||
* *Note:* The range must be a [single line](#Range.isSingleLine) and it must
|
||||
* [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems).
|
||||
*/
|
||||
range?: Range;
|
||||
/**
|
||||
* An optional set of characters that when pressed while this completion is active will accept it first and
|
||||
* then type that character. *Note* that all commit characters should have `length=1` and that superfluous
|
||||
* characters will be ignored.
|
||||
*/
|
||||
commitCharacters?: string[];
|
||||
/**
|
||||
* @deprecated **Deprecated** in favor of `CompletionItem.insertText` and `CompletionItem.range`.
|
||||
*
|
||||
* ~~An [edit](#TextEdit) which is applied to a document when selecting
|
||||
* this completion. When an edit is provided the value of
|
||||
* [insertText](#CompletionItem.insertText) is ignored.~~
|
||||
*
|
||||
* ~~The [range](#Range) of the edit must be single-line and on the same
|
||||
* line completions were [requested](#CompletionItemProvider.provideCompletionItems) at.~~
|
||||
*/
|
||||
textEdit?: model.ISingleEditOperation;
|
||||
/**
|
||||
* An optional array of additional text edits that are applied when
|
||||
* selecting this completion. Edits must not overlap with the main edit
|
||||
* nor with themselves.
|
||||
*/
|
||||
additionalTextEdits?: model.ISingleEditOperation[];
|
||||
}
|
||||
/**
|
||||
* Represents a collection of [completion items](#CompletionItem) to be presented
|
||||
* in the editor.
|
||||
*/
|
||||
export interface CompletionList {
|
||||
/**
|
||||
* This list it not complete. Further typing should result in recomputing
|
||||
* this list.
|
||||
*/
|
||||
isIncomplete?: boolean;
|
||||
/**
|
||||
* The completion items.
|
||||
*/
|
||||
items: CompletionItem[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains additional information about the context in which
|
||||
* [completion provider](#CompletionItemProvider.provideCompletionItems) is triggered.
|
||||
*/
|
||||
export interface CompletionContext {
|
||||
/**
|
||||
* How the completion was triggered.
|
||||
*/
|
||||
triggerKind: modes.SuggestTriggerKind;
|
||||
|
||||
/**
|
||||
* Character that triggered the completion item provider.
|
||||
*
|
||||
* `undefined` if provider was not triggered by a character.
|
||||
*/
|
||||
triggerCharacter?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The completion item provider interface defines the contract between extensions and
|
||||
* the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense).
|
||||
*
|
||||
* When computing *complete* completion items is expensive, providers can optionally implement
|
||||
* the `resolveCompletionItem`-function. In that case it is enough to return completion
|
||||
* items with a [label](#CompletionItem.label) from the
|
||||
* [provideCompletionItems](#CompletionItemProvider.provideCompletionItems)-function. Subsequently,
|
||||
* when a completion item is shown in the UI and gains focus this provider is asked to resolve
|
||||
* the item, like adding [doc-comment](#CompletionItem.documentation) or [details](#CompletionItem.detail).
|
||||
*/
|
||||
export interface CompletionItemProvider {
|
||||
triggerCharacters?: string[];
|
||||
/**
|
||||
* Provide completion items for the given position and document.
|
||||
*/
|
||||
provideCompletionItems(document: model.ITextModel, position: Position, token: CancellationToken, context: CompletionContext): CompletionItem[] | Thenable<CompletionItem[]> | CompletionList | Thenable<CompletionList>;
|
||||
|
||||
/**
|
||||
* Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation)
|
||||
* or [details](#CompletionItem.detail).
|
||||
*
|
||||
* The editor will only resolve a completion item once.
|
||||
*/
|
||||
resolveCompletionItem?(item: CompletionItem, token: CancellationToken): CompletionItem | Thenable<CompletionItem>;
|
||||
}
|
||||
|
||||
interface ISuggestion2 extends modes.ISuggestion {
|
||||
_actual: CompletionItem;
|
||||
}
|
||||
function convertKind(kind: CompletionItemKind): modes.SuggestionType {
|
||||
switch (kind) {
|
||||
case CompletionItemKind.Method: return 'method';
|
||||
case CompletionItemKind.Function: return 'function';
|
||||
case CompletionItemKind.Constructor: return 'constructor';
|
||||
case CompletionItemKind.Field: return 'field';
|
||||
case CompletionItemKind.Variable: return 'variable';
|
||||
case CompletionItemKind.Class: return 'class';
|
||||
case CompletionItemKind.Interface: return 'interface';
|
||||
case CompletionItemKind.Module: return 'module';
|
||||
case CompletionItemKind.Property: return 'property';
|
||||
case CompletionItemKind.Unit: return 'unit';
|
||||
case CompletionItemKind.Value: return 'value';
|
||||
case CompletionItemKind.Enum: return 'enum';
|
||||
case CompletionItemKind.Keyword: return 'keyword';
|
||||
case CompletionItemKind.Snippet: return 'snippet';
|
||||
case CompletionItemKind.Text: return 'text';
|
||||
case CompletionItemKind.Color: return 'color';
|
||||
case CompletionItemKind.File: return 'file';
|
||||
case CompletionItemKind.Reference: return 'reference';
|
||||
case CompletionItemKind.Folder: return 'folder';
|
||||
}
|
||||
return 'property';
|
||||
}
|
||||
|
||||
class SuggestAdapter {
|
||||
|
||||
private _provider: CompletionItemProvider;
|
||||
|
||||
constructor(provider: CompletionItemProvider) {
|
||||
this._provider = provider;
|
||||
}
|
||||
|
||||
private static from(item: CompletionItem, position: Position, wordStartPos: Position): ISuggestion2 {
|
||||
let suggestion: ISuggestion2 = {
|
||||
_actual: item,
|
||||
label: item.label,
|
||||
insertText: item.label,
|
||||
type: convertKind(item.kind),
|
||||
detail: item.detail,
|
||||
documentation: item.documentation,
|
||||
command: item.command,
|
||||
sortText: item.sortText,
|
||||
filterText: item.filterText,
|
||||
snippetType: 'internal',
|
||||
additionalTextEdits: item.additionalTextEdits,
|
||||
commitCharacters: item.commitCharacters
|
||||
};
|
||||
let editRange = item.textEdit ? item.textEdit.range : item.range;
|
||||
if (editRange) {
|
||||
let isSingleLine = (editRange.startLineNumber === editRange.endLineNumber);
|
||||
|
||||
// invalid text edit
|
||||
if (!isSingleLine || editRange.startLineNumber !== position.lineNumber) {
|
||||
console.warn('INVALID range, must be single line and on the same line');
|
||||
return null;
|
||||
}
|
||||
|
||||
// insert the text of the edit and create a dedicated
|
||||
// suggestion-container with overwrite[Before|After]
|
||||
suggestion.overwriteBefore = position.column - editRange.startColumn;
|
||||
suggestion.overwriteAfter = editRange.endColumn - position.column;
|
||||
} else {
|
||||
suggestion.overwriteBefore = position.column - wordStartPos.column;
|
||||
suggestion.overwriteAfter = 0;
|
||||
}
|
||||
if (item.textEdit) {
|
||||
suggestion.insertText = item.textEdit.text;
|
||||
} else if (typeof item.insertText === 'object' && typeof item.insertText.value === 'string') {
|
||||
suggestion.insertText = item.insertText.value;
|
||||
suggestion.snippetType = 'textmate';
|
||||
} else if (typeof item.insertText === 'string') {
|
||||
suggestion.insertText = item.insertText;
|
||||
}
|
||||
return suggestion;
|
||||
}
|
||||
|
||||
provideCompletionItems(model: model.ITextModel, position: Position, context: modes.SuggestContext, token: CancellationToken): Thenable<modes.ISuggestResult> {
|
||||
const result = this._provider.provideCompletionItems(model, position, token, context);
|
||||
return toThenable<CompletionItem[] | CompletionList>(result).then(value => {
|
||||
const result: modes.ISuggestResult = {
|
||||
suggestions: []
|
||||
};
|
||||
|
||||
// default text edit start
|
||||
let wordStartPos = position;
|
||||
const word = model.getWordUntilPosition(position);
|
||||
if (word) {
|
||||
wordStartPos = new Position(wordStartPos.lineNumber, word.startColumn);
|
||||
}
|
||||
|
||||
let list: CompletionList;
|
||||
if (Array.isArray(value)) {
|
||||
list = {
|
||||
items: value,
|
||||
isIncomplete: false
|
||||
};
|
||||
} else if (typeof value === 'object' && Array.isArray(value.items)) {
|
||||
list = value;
|
||||
result.incomplete = list.isIncomplete;
|
||||
} else if (!value) {
|
||||
// undefined and null are valid results
|
||||
return undefined;
|
||||
} else {
|
||||
// warn about everything else
|
||||
console.warn('INVALID result from completion provider. expected CompletionItem-array or CompletionList but got:', value);
|
||||
}
|
||||
|
||||
for (let i = 0; i < list.items.length; i++) {
|
||||
const item = list.items[i];
|
||||
const suggestion = SuggestAdapter.from(item, position, wordStartPos);
|
||||
if (suggestion) {
|
||||
result.suggestions.push(suggestion);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
resolveCompletionItem(model: model.ITextModel, position: Position, suggestion: modes.ISuggestion, token: CancellationToken): Thenable<modes.ISuggestion> {
|
||||
if (typeof this._provider.resolveCompletionItem !== 'function') {
|
||||
return TPromise.as(suggestion);
|
||||
}
|
||||
|
||||
let item = (<ISuggestion2>suggestion)._actual;
|
||||
if (!item) {
|
||||
return TPromise.as(suggestion);
|
||||
}
|
||||
|
||||
return toThenable(this._provider.resolveCompletionItem(item, token)).then(resolvedItem => {
|
||||
let wordStartPos = position;
|
||||
const word = model.getWordUntilPosition(position);
|
||||
if (word) {
|
||||
wordStartPos = new Position(wordStartPos.lineNumber, word.startColumn);
|
||||
}
|
||||
return SuggestAdapter.from(resolvedItem, position, wordStartPos);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export function createMonacoLanguagesAPI(): typeof monaco.languages {
|
||||
return {
|
||||
register: register,
|
||||
getLanguages: getLanguages,
|
||||
onLanguage: onLanguage,
|
||||
getEncodedLanguageId: getEncodedLanguageId,
|
||||
register: <any>register,
|
||||
getLanguages: <any>getLanguages,
|
||||
onLanguage: <any>onLanguage,
|
||||
getEncodedLanguageId: <any>getEncodedLanguageId,
|
||||
|
||||
// provider methods
|
||||
setLanguageConfiguration: setLanguageConfiguration,
|
||||
setTokensProvider: setTokensProvider,
|
||||
setMonarchTokensProvider: setMonarchTokensProvider,
|
||||
registerReferenceProvider: registerReferenceProvider,
|
||||
registerRenameProvider: registerRenameProvider,
|
||||
registerCompletionItemProvider: registerCompletionItemProvider,
|
||||
registerSignatureHelpProvider: registerSignatureHelpProvider,
|
||||
registerHoverProvider: registerHoverProvider,
|
||||
registerDocumentSymbolProvider: registerDocumentSymbolProvider,
|
||||
registerDocumentHighlightProvider: registerDocumentHighlightProvider,
|
||||
registerDefinitionProvider: registerDefinitionProvider,
|
||||
registerImplementationProvider: registerImplementationProvider,
|
||||
registerTypeDefinitionProvider: registerTypeDefinitionProvider,
|
||||
registerCodeLensProvider: registerCodeLensProvider,
|
||||
registerCodeActionProvider: registerCodeActionProvider,
|
||||
registerDocumentFormattingEditProvider: registerDocumentFormattingEditProvider,
|
||||
registerDocumentRangeFormattingEditProvider: registerDocumentRangeFormattingEditProvider,
|
||||
registerOnTypeFormattingEditProvider: registerOnTypeFormattingEditProvider,
|
||||
registerLinkProvider: registerLinkProvider,
|
||||
registerColorProvider: registerColorProvider,
|
||||
registerFoldingRangeProvider: registerFoldingRangeProvider,
|
||||
setLanguageConfiguration: <any>setLanguageConfiguration,
|
||||
setTokensProvider: <any>setTokensProvider,
|
||||
setMonarchTokensProvider: <any>setMonarchTokensProvider,
|
||||
registerReferenceProvider: <any>registerReferenceProvider,
|
||||
registerRenameProvider: <any>registerRenameProvider,
|
||||
registerCompletionItemProvider: <any>registerCompletionItemProvider,
|
||||
registerSignatureHelpProvider: <any>registerSignatureHelpProvider,
|
||||
registerHoverProvider: <any>registerHoverProvider,
|
||||
registerDocumentSymbolProvider: <any>registerDocumentSymbolProvider,
|
||||
registerDocumentHighlightProvider: <any>registerDocumentHighlightProvider,
|
||||
registerDefinitionProvider: <any>registerDefinitionProvider,
|
||||
registerImplementationProvider: <any>registerImplementationProvider,
|
||||
registerTypeDefinitionProvider: <any>registerTypeDefinitionProvider,
|
||||
registerCodeLensProvider: <any>registerCodeLensProvider,
|
||||
registerCodeActionProvider: <any>registerCodeActionProvider,
|
||||
registerDocumentFormattingEditProvider: <any>registerDocumentFormattingEditProvider,
|
||||
registerDocumentRangeFormattingEditProvider: <any>registerDocumentRangeFormattingEditProvider,
|
||||
registerOnTypeFormattingEditProvider: <any>registerOnTypeFormattingEditProvider,
|
||||
registerLinkProvider: <any>registerLinkProvider,
|
||||
registerColorProvider: <any>registerColorProvider,
|
||||
registerFoldingRangeProvider: <any>registerFoldingRangeProvider,
|
||||
|
||||
// enums
|
||||
DocumentHighlightKind: modes.DocumentHighlightKind,
|
||||
CompletionItemKind: CompletionItemKind,
|
||||
SymbolKind: modes.SymbolKind,
|
||||
IndentAction: IndentAction,
|
||||
SuggestTriggerKind: modes.SuggestTriggerKind,
|
||||
CommentThreadCollapsibleState: modes.CommentThreadCollapsibleState,
|
||||
FoldingRangeKind: modes.FoldingRangeKind
|
||||
DocumentHighlightKind: standaloneEnums.DocumentHighlightKind,
|
||||
CompletionItemKind: standaloneEnums.CompletionItemKind,
|
||||
CompletionItemInsertTextRule: standaloneEnums.CompletionItemInsertTextRule,
|
||||
SymbolKind: standaloneEnums.SymbolKind,
|
||||
IndentAction: standaloneEnums.IndentAction,
|
||||
CompletionTriggerKind: standaloneEnums.CompletionTriggerKind,
|
||||
SignatureHelpTriggerKind: standaloneEnums.SignatureHelpTriggerKind,
|
||||
|
||||
// classes
|
||||
FoldingRangeKind: modes.FoldingRangeKind,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,48 +2,46 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ContextMenuService } from 'vs/platform/contextview/browser/contextMenuService';
|
||||
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { ContextViewService } from 'vs/platform/contextview/browser/contextViewService';
|
||||
import { createDecorator, IInstantiationService, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { MarkerService } from 'vs/platform/markers/common/markerService';
|
||||
import { IMarkerService } from 'vs/platform/markers/common/markers';
|
||||
import { IProgressService } from 'vs/platform/progress/common/progress';
|
||||
import { IStorageService, NullStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
|
||||
import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
|
||||
import { EditorWorkerServiceImpl } from 'vs/editor/common/services/editorWorkerServiceImpl';
|
||||
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
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 } from 'vs/editor/standalone/browser/simpleServices';
|
||||
import { StandaloneCodeEditorServiceImpl } from 'vs/editor/standalone/browser/standaloneCodeServiceImpl';
|
||||
import {
|
||||
SimpleConfigurationService, SimpleResourceConfigurationService, SimpleMenuService,
|
||||
SimpleProgressService, StandaloneCommandService, StandaloneKeybindingService, SimpleNotificationService,
|
||||
StandaloneTelemetryService, SimpleWorkspaceContextService, SimpleDialogService, SimpleBulkEditService
|
||||
} from 'vs/editor/standalone/browser/simpleServices';
|
||||
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
|
||||
import { IMenuService } from 'vs/platform/actions/common/actions';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { StandaloneThemeServiceImpl } from 'vs/editor/standalone/browser/standaloneThemeServiceImpl';
|
||||
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { IMenuService } from 'vs/platform/actions/common/actions';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ContextKeyService } from 'vs/platform/contextkey/browser/contextKeyService';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ContextMenuService } from 'vs/platform/contextview/browser/contextMenuService';
|
||||
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { ContextViewService } from 'vs/platform/contextview/browser/contextViewService';
|
||||
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
|
||||
import { IInstantiationService, ServiceIdentifier, createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { IListService, ListService } from 'vs/platform/list/browser/listService';
|
||||
import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService';
|
||||
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 { IStorageService, InMemoryStorageService } from 'vs/platform/storage/common/storage';
|
||||
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';
|
||||
|
||||
export interface IEditorOverrideServices {
|
||||
[index: string]: any;
|
||||
@@ -119,8 +117,12 @@ export module StaticServices {
|
||||
|
||||
export const resourceConfigurationService = define(ITextResourceConfigurationService, () => new SimpleResourceConfigurationService(configurationServiceImpl));
|
||||
|
||||
export const resourcePropertiesService = define(ITextResourcePropertiesService, () => new SimpleResourcePropertiesService(configurationServiceImpl));
|
||||
|
||||
export const contextService = define(IWorkspaceContextService, () => new SimpleWorkspaceContextService());
|
||||
|
||||
export const labelService = define(ILabelService, () => new SimpleUriLabelService());
|
||||
|
||||
export const telemetryService = define(ITelemetryService, () => new StandaloneTelemetryService());
|
||||
|
||||
export const dialogService = define(IDialogService, () => new SimpleDialogService());
|
||||
@@ -131,7 +133,7 @@ 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)));
|
||||
export const modelService = define(IModelService, (o) => new ModelServiceImpl(markerService.get(o), configurationService.get(o), resourcePropertiesService.get(o)));
|
||||
|
||||
export const editorWorkerService = define(IEditorWorkerService, (o) => new EditorWorkerServiceImpl(modelService.get(o), resourceConfigurationService.get(o)));
|
||||
|
||||
@@ -141,7 +143,7 @@ export module StaticServices {
|
||||
|
||||
export const progressService = define(IProgressService, () => new SimpleProgressService());
|
||||
|
||||
export const storageService = define(IStorageService, () => NullStorageService);
|
||||
export const storageService = define(IStorageService, () => new InMemoryStorageService());
|
||||
|
||||
export const logService = define(ILogService, () => new NullLogService());
|
||||
|
||||
@@ -162,9 +164,10 @@ export class DynamicStandaloneServices extends Disposable {
|
||||
const configurationService = this.get(IConfigurationService);
|
||||
const notificationService = this.get(INotificationService);
|
||||
const telemetryService = this.get(ITelemetryService);
|
||||
const themeService = this.get(IThemeService);
|
||||
|
||||
let ensure = <T>(serviceId: ServiceIdentifier<T>, factory: () => T): T => {
|
||||
let value: T = null;
|
||||
let value: T | null = null;
|
||||
if (overrides) {
|
||||
value = overrides[serviceId.toString()];
|
||||
}
|
||||
@@ -181,13 +184,13 @@ export class DynamicStandaloneServices extends Disposable {
|
||||
|
||||
let commandService = ensure(ICommandService, () => new StandaloneCommandService(this._instantiationService));
|
||||
|
||||
ensure(IKeybindingService, () => this._register(new StandaloneKeybindingService(contextKeyService, commandService, telemetryService, notificationService, domElement)));
|
||||
let keybindingService = ensure(IKeybindingService, () => this._register(new StandaloneKeybindingService(contextKeyService, commandService, telemetryService, notificationService, domElement)));
|
||||
|
||||
let contextViewService = ensure(IContextViewService, () => this._register(new ContextViewService(domElement, telemetryService, new NullLogService())));
|
||||
|
||||
ensure(IContextMenuService, () => this._register(new ContextMenuService(domElement, telemetryService, notificationService, contextViewService)));
|
||||
ensure(IContextMenuService, () => this._register(new ContextMenuService(domElement, telemetryService, notificationService, contextViewService, keybindingService, themeService)));
|
||||
|
||||
ensure(IMenuService, () => new SimpleMenuService(commandService));
|
||||
ensure(IMenuService, () => new MenuService(commandService));
|
||||
|
||||
ensure(IBulkEditService, () => new SimpleBulkEditService(StaticServices.modelService.get(IModelService)));
|
||||
}
|
||||
|
||||
@@ -2,19 +2,18 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { TokenTheme, ITokenThemeRule, generateTokensCSSForColorMap } from 'vs/editor/common/modes/supports/tokenization';
|
||||
import { IStandaloneThemeService, BuiltinTheme, IStandaloneThemeData, IStandaloneTheme } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { vs, vs_dark, hc_black } from 'vs/editor/standalone/common/themes';
|
||||
import * as dom from 'vs/base/browser/dom';
|
||||
import { TokenizationRegistry } from 'vs/editor/common/modes';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { Extensions, IColorRegistry, ColorIdentifier } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { Extensions as ThemingExtensions, IThemingRegistry, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { TokenizationRegistry } from 'vs/editor/common/modes';
|
||||
import { ITokenThemeRule, TokenTheme, generateTokensCSSForColorMap } from 'vs/editor/common/modes/supports/tokenization';
|
||||
import { BuiltinTheme, IStandaloneTheme, IStandaloneThemeData, IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { hc_black, vs, vs_dark } from 'vs/editor/standalone/common/themes';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { ColorIdentifier, Extensions, IColorRegistry } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { Extensions as ThemingExtensions, ICssStyleCollector, IIconTheme, IThemingRegistry } from 'vs/platform/theme/common/themeService';
|
||||
|
||||
const VS_THEME_NAME = 'vs';
|
||||
const VS_DARK_THEME_NAME = 'vs-dark';
|
||||
@@ -28,9 +27,9 @@ class StandaloneTheme implements IStandaloneTheme {
|
||||
public readonly themeName: string;
|
||||
|
||||
private themeData: IStandaloneThemeData;
|
||||
private colors: { [colorId: string]: Color };
|
||||
private defaultColors: { [colorId: string]: Color };
|
||||
private _tokenTheme: TokenTheme;
|
||||
private colors: { [colorId: string]: Color } | null;
|
||||
private defaultColors: { [colorId: string]: Color | null; };
|
||||
private _tokenTheme: TokenTheme | null;
|
||||
|
||||
constructor(name: string, standaloneThemeData: IStandaloneThemeData) {
|
||||
this.themeData = standaloneThemeData;
|
||||
@@ -78,7 +77,7 @@ class StandaloneTheme implements IStandaloneTheme {
|
||||
return this.colors;
|
||||
}
|
||||
|
||||
public getColor(colorId: ColorIdentifier, useDefault?: boolean): Color {
|
||||
public getColor(colorId: ColorIdentifier, useDefault?: boolean): Color | null {
|
||||
const color = this.getColors()[colorId];
|
||||
if (color) {
|
||||
return color;
|
||||
@@ -89,7 +88,7 @@ class StandaloneTheme implements IStandaloneTheme {
|
||||
return null;
|
||||
}
|
||||
|
||||
private getDefault(colorId: ColorIdentifier): Color {
|
||||
private getDefault(colorId: ColorIdentifier): Color | null {
|
||||
let color = this.defaultColors[colorId];
|
||||
if (color) {
|
||||
return color;
|
||||
@@ -100,7 +99,7 @@ class StandaloneTheme implements IStandaloneTheme {
|
||||
}
|
||||
|
||||
public defines(colorId: ColorIdentifier): boolean {
|
||||
return this.getColors().hasOwnProperty(colorId);
|
||||
return Object.prototype.hasOwnProperty.call(this.getColors(), colorId);
|
||||
}
|
||||
|
||||
public get type() {
|
||||
@@ -114,7 +113,7 @@ class StandaloneTheme implements IStandaloneTheme {
|
||||
public get tokenTheme(): TokenTheme {
|
||||
if (!this._tokenTheme) {
|
||||
let rules: ITokenThemeRule[] = [];
|
||||
let encodedTokensColors = [];
|
||||
let encodedTokensColors: string[] = [];
|
||||
if (this.themeData.inherit) {
|
||||
let baseData = getBuiltinRules(this.themeData.base);
|
||||
rules = baseData.rules;
|
||||
@@ -164,10 +163,12 @@ export class StandaloneThemeServiceImpl implements IStandaloneThemeService {
|
||||
private _styleElement: HTMLStyleElement;
|
||||
private _theme: IStandaloneTheme;
|
||||
private readonly _onThemeChange: Emitter<IStandaloneTheme>;
|
||||
private readonly _onIconThemeChange: Emitter<IIconTheme>;
|
||||
private environment: IEnvironmentService = Object.create(null);
|
||||
|
||||
constructor() {
|
||||
this._onThemeChange = new Emitter<IStandaloneTheme>();
|
||||
this._onIconThemeChange = new Emitter<IIconTheme>();
|
||||
|
||||
this._knownThemes = new Map<string, StandaloneTheme>();
|
||||
this._knownThemes.set(VS_THEME_NAME, newBuiltInTheme(VS_THEME_NAME));
|
||||
@@ -215,6 +216,10 @@ export class StandaloneThemeServiceImpl implements IStandaloneThemeService {
|
||||
} else {
|
||||
theme = this._knownThemes.get(VS_THEME_NAME);
|
||||
}
|
||||
if (this._theme === theme) {
|
||||
// Nothing to do
|
||||
return theme.id;
|
||||
}
|
||||
this._theme = theme;
|
||||
|
||||
let cssRules: string[] = [];
|
||||
@@ -240,4 +245,16 @@ export class StandaloneThemeServiceImpl implements IStandaloneThemeService {
|
||||
|
||||
return theme.id;
|
||||
}
|
||||
|
||||
public getIconTheme(): IIconTheme {
|
||||
return {
|
||||
hasFileIcons: false,
|
||||
hasFolderIcons: false,
|
||||
hidesExplorerArrows: false
|
||||
};
|
||||
}
|
||||
|
||||
public get onIconThemeChange(): Event<IIconTheme> {
|
||||
return this._onIconThemeChange.event;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { registerEditorAction, EditorAction, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction, ServicesAccessor, registerEditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { IStandaloneThemeService } from 'vs/editor/standalone/common/standaloneThemeService';
|
||||
|
||||
class ToggleHighContrast extends EditorAction {
|
||||
|
||||
private _originalThemeName: string;
|
||||
private _originalThemeName: string | null;
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
|
||||
Reference in New Issue
Block a user