Merge from vscode 2f984aad710215f4e4684a035bb02f55d1a9e2cc (#9819)

This commit is contained in:
Anthony Dresser
2020-04-01 00:44:39 -07:00
committed by GitHub
parent 0e27aaa61f
commit 0bfbdc62ed
247 changed files with 5402 additions and 3311 deletions

View File

@@ -70,12 +70,6 @@ class InspectEditorTokensController extends Disposable implements IEditorContrib
this._register(this._editor.onDidChangeModel((e) => this.stop()));
this._register(this._editor.onDidChangeModelLanguage((e) => this.stop()));
this._register(this._editor.onKeyUp((e) => e.keyCode === KeyCode.Escape && this.stop()));
this._register(this._themeService.onDidColorThemeChange(_ => {
if (this._widget) {
this.stop();
this.launch();
}
}));
}
public dispose(): void {
@@ -199,12 +193,11 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
private readonly _editor: IActiveCodeEditor;
private readonly _modeService: IModeService;
private readonly _themeService: IWorkbenchThemeService;
private readonly _textMateService: ITextMateService;
private readonly _notificationService: INotificationService;
private readonly _configurationService: IConfigurationService;
private readonly _model: ITextModel;
private readonly _domNode: HTMLElement;
private readonly _grammar: Promise<IGrammar | null>;
private readonly _semanticTokens: Promise<SemanticTokensResult | null>;
private readonly _currentRequestCancellationTokenSource: CancellationTokenSource;
constructor(
@@ -220,16 +213,17 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
this._editor = editor;
this._modeService = modeService;
this._themeService = themeService;
this._textMateService = textMateService;
this._notificationService = notificationService;
this._configurationService = configurationService;
this._model = this._editor.getModel();
this._domNode = document.createElement('div');
this._domNode.className = 'token-inspect-widget';
this._currentRequestCancellationTokenSource = new CancellationTokenSource();
this._grammar = textMateService.createGrammar(this._model.getLanguageIdentifier().language);
this._semanticTokens = this._computeSemanticTokens();
this._beginCompute(this._editor.getPosition());
this._register(this._editor.onDidChangeCursorPosition((e) => this._beginCompute(this._editor.getPosition())));
this._register(themeService.onDidColorThemeChange(_ => this._beginCompute(this._editor.getPosition())));
this._register(configurationService.onDidChangeConfiguration(e => e.affectsConfiguration('editor.semanticHighlighting.enabled') && this._beginCompute(this._editor.getPosition())));
this._editor.addContentWidget(this);
}
@@ -245,10 +239,13 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
}
private _beginCompute(position: Position): void {
const grammar = this._textMateService.createGrammar(this._model.getLanguageIdentifier().language);
const semanticTokens = this._computeSemanticTokens();
dom.clearNode(this._domNode);
this._domNode.appendChild(document.createTextNode(nls.localize('inspectTMScopesWidget.loading', "Loading...")));
Promise.all([this._grammar, this._semanticTokens]).then(([grammar, semanticTokens]) => {
Promise.all([grammar, semanticTokens]).then(([grammar, semanticTokens]) => {
if (this._isDisposed) {
return;
}
@@ -551,9 +548,9 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
} else if (TokenStylingRule.is(definition)) {
const scope = theme.getTokenStylingRuleScope(definition);
if (scope === 'setting') {
return `User settings: ${definition.selector.selectorString} - ${this._renderStyleProperty(definition.style, property)}`;
return `User settings: ${definition.selector.id} - ${this._renderStyleProperty(definition.style, property)}`;
} else if (scope === 'theme') {
return `Color theme: ${definition.selector.selectorString} - ${this._renderStyleProperty(definition.style, property)}`;
return `Color theme: ${definition.selector.id} - ${this._renderStyleProperty(definition.style, property)}`;
}
return '';
} else {

View File

@@ -11,6 +11,7 @@ import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
import { IEditorContribution } from 'vs/editor/common/editorCommon';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
/**
* Shows a message when opening a large file which has been memory optimized (and features disabled).
@@ -23,9 +24,13 @@ export class LargeFileOptimizationsWarner extends Disposable implements IEditorC
private readonly _editor: ICodeEditor,
@INotificationService private readonly _notificationService: INotificationService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@IStorageKeysSyncRegistryService storageKeysSyncRegistryService: IStorageKeysSyncRegistryService
) {
super();
// opt-in to syncing
const neverShowAgainId = 'editor.contrib.largeFileOptimizationsWarner';
storageKeysSyncRegistryService.registerStorageKey({ key: neverShowAgainId, version: 1 });
this._register(this._editor.onDidChangeModel((e) => {
const model = this._editor.getModel();
@@ -56,7 +61,7 @@ export class LargeFileOptimizationsWarner extends Disposable implements IEditorC
});
}
}
], { neverShowAgain: { id: 'editor.contrib.largeFileOptimizationsWarner' } });
], { neverShowAgain: { id: neverShowAgainId } });
}
}));
}

View File

@@ -15,6 +15,7 @@ import { URI } from 'vs/base/common/uri';
import { ITextModel } from 'vs/editor/common/model';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common/storageKeys';
/**
* Shows a message when semantic tokens are shown the first time.
@@ -30,10 +31,15 @@ export class SemanticTokensHelp extends Disposable implements IEditorContributio
@INotificationService _notificationService: INotificationService,
@IOpenerService _openerService: IOpenerService,
@IWorkbenchThemeService _themeService: IWorkbenchThemeService,
@IEditorService _editorService: IEditorService
@IEditorService _editorService: IEditorService,
@IStorageKeysSyncRegistryService storageKeysSyncRegistryService: IStorageKeysSyncRegistryService
) {
super();
// opt-in to syncing
const neverShowAgainId = 'editor.contrib.semanticTokensHelp';
storageKeysSyncRegistryService.registerStorageKey({ key: neverShowAgainId, version: 1 });
const toDispose = this._register(new DisposableStore());
const localToDispose = toDispose.add(new DisposableStore());
const installChangeTokenListener = (model: ITextModel) => {
@@ -75,7 +81,7 @@ export class SemanticTokensHelp extends Disposable implements IEditorContributio
_openerService.open(URI.parse(url));
}
}
], { neverShowAgain: { id: 'editor.contrib.semanticTokensHelp' } });
], { neverShowAgain: { id: neverShowAgainId } });
}));
};