mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-10 18:22:34 -05:00
Merge from vscode 099a7622e6e90dbcc226e428d4e35a72cb19ecbc (#9646)
* Merge from vscode 099a7622e6e90dbcc226e428d4e35a72cb19ecbc * fix strict
This commit is contained in:
@@ -10,7 +10,9 @@ import './inspectKeybindings';
|
||||
import './largeFileOptimizations';
|
||||
import './inspectEditorTokens/inspectEditorTokens';
|
||||
import './quickaccess/gotoLineQuickAccess';
|
||||
import './quickaccess/gotoSymbolQuickAccess';
|
||||
import './saveParticipants';
|
||||
import './semanticTokensHelp';
|
||||
import './toggleColumnSelection';
|
||||
import './toggleMinimap';
|
||||
import './toggleMultiCursorModifier';
|
||||
|
||||
@@ -26,7 +26,7 @@ import { findMatchingThemeRule } from 'vs/workbench/services/textMate/common/TMH
|
||||
import { ITextMateService, IGrammar, IToken, StackElement } from 'vs/workbench/services/textMate/common/textMateService';
|
||||
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
||||
import { ColorThemeData, TokenStyleDefinitions, TokenStyleDefinition } from 'vs/workbench/services/themes/common/colorThemeData';
|
||||
import { ColorThemeData, TokenStyleDefinitions, TokenStyleDefinition, TextMateThemingRuleDefinitions } from 'vs/workbench/services/themes/common/colorThemeData';
|
||||
import { TokenStylingRule, TokenStyleData, TokenStyle } from 'vs/platform/theme/common/tokenClassificationRegistry';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
||||
@@ -260,6 +260,9 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
|
||||
}
|
||||
|
||||
private _isSemanticColoringEnabled() {
|
||||
if (!this._themeService.getColorTheme().semanticHighlighting) {
|
||||
return false;
|
||||
}
|
||||
const options = this._configurationService.getValue<IEditorSemanticHighlightingOptions>('editor.semanticHighlighting', { overrideIdentifier: this._model.getLanguageIdentifier().language, resource: this._model.uri });
|
||||
return options && options.enabled;
|
||||
}
|
||||
@@ -303,7 +306,7 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
|
||||
const allDefValues = []; // remember the order
|
||||
// first collect to detect when the same rule is used fro multiple properties
|
||||
for (let property of properties) {
|
||||
if (semanticTokenInfo.metadata[property]) {
|
||||
if (semanticTokenInfo.metadata[property] !== undefined) {
|
||||
const definition = semanticTokenInfo.definitions[property];
|
||||
const defValue = this._renderTokenStyleDefinition(definition, property);
|
||||
let properties = propertiesByDefValue[defValue];
|
||||
@@ -532,11 +535,11 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
|
||||
|
||||
const isTokenStylingRule = (d: any): d is TokenStylingRule => !!d.value;
|
||||
if (Array.isArray(definition)) {
|
||||
for (const d of definition) {
|
||||
const matchingRule = findMatchingThemeRule(theme, d, false);
|
||||
if (matchingRule) {
|
||||
return `${escape(d.join(' '))}<br><code class="tiw-theme-selector">${matchingRule.rawSelector}\n${JSON.stringify(matchingRule.settings, null, '\t')}</code>`;
|
||||
}
|
||||
const scopesDefinition: TextMateThemingRuleDefinitions = {};
|
||||
theme.resolveScopes(definition, scopesDefinition);
|
||||
const matchingRule = scopesDefinition[property];
|
||||
if (matchingRule && scopesDefinition.scope) {
|
||||
return `${escape(scopesDefinition.scope.join(' '))}<br><code class="tiw-theme-selector">${matchingRule.scope}\n${JSON.stringify(matchingRule.settings, null, '\t')}</code>`;
|
||||
}
|
||||
return '';
|
||||
} else if (isTokenStylingRule(definition)) {
|
||||
|
||||
@@ -11,29 +11,45 @@ import { IRange } from 'vs/editor/common/core/range';
|
||||
import { AbstractGotoLineQuickAccessProvider } from 'vs/editor/contrib/quickAccess/gotoLineQuickAccess';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IQuickAccessRegistry, Extensions } from 'vs/platform/quickinput/common/quickAccess';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor';
|
||||
|
||||
export class GotoLineQuickAccessProvider extends AbstractGotoLineQuickAccessProvider {
|
||||
|
||||
readonly onDidActiveTextEditorControlChange = this.editorService.onDidActiveEditorChange;
|
||||
protected readonly onDidActiveTextEditorControlChange = this.editorService.onDidActiveEditorChange;
|
||||
|
||||
constructor(@IEditorService private readonly editorService: IEditorService) {
|
||||
constructor(
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
) {
|
||||
super();
|
||||
}
|
||||
|
||||
get activeTextEditorControl() {
|
||||
private get configuration() {
|
||||
const editorConfig = this.configurationService.getValue<IWorkbenchEditorConfiguration>().workbench.editor;
|
||||
|
||||
return {
|
||||
openEditorPinned: !editorConfig.enablePreviewFromQuickOpen,
|
||||
};
|
||||
}
|
||||
|
||||
protected get activeTextEditorControl() {
|
||||
return this.editorService.activeTextEditorControl;
|
||||
}
|
||||
|
||||
protected gotoLine(editor: IEditor, range: IRange, keyMods: IKeyMods): void {
|
||||
protected gotoLocation(editor: IEditor, range: IRange, keyMods: IKeyMods, forceSideBySide?: boolean): void {
|
||||
|
||||
// Check for sideBySide use
|
||||
if (keyMods.ctrlCmd && this.editorService.activeEditor) {
|
||||
this.editorService.openEditor(this.editorService.activeEditor, { selection: range, pinned: keyMods.alt }, SIDE_GROUP);
|
||||
if ((keyMods.ctrlCmd || forceSideBySide) && this.editorService.activeEditor) {
|
||||
this.editorService.openEditor(this.editorService.activeEditor, {
|
||||
selection: range,
|
||||
pinned: keyMods.alt || this.configuration.openEditorPinned
|
||||
}, SIDE_GROUP);
|
||||
}
|
||||
|
||||
// Otherwise let parent handle it
|
||||
else {
|
||||
super.gotoLine(editor, range, keyMods);
|
||||
super.gotoLocation(editor, range, keyMods);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { IKeyMods } from 'vs/platform/quickinput/common/quickInput';
|
||||
import { IEditor } from 'vs/editor/common/editorCommon';
|
||||
import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IRange } from 'vs/editor/common/core/range';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IQuickAccessRegistry, Extensions } from 'vs/platform/quickinput/common/quickAccess';
|
||||
import { AbstractGotoSymbolQuickAccessProvider } from 'vs/editor/contrib/quickAccess/gotoSymbolQuickAccess';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor';
|
||||
|
||||
export class GotoSymbolQuickAccessProvider extends AbstractGotoSymbolQuickAccessProvider {
|
||||
|
||||
protected readonly onDidActiveTextEditorControlChange = this.editorService.onDidActiveEditorChange;
|
||||
|
||||
constructor(
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
) {
|
||||
super({
|
||||
openSideBySideDirection: () => this.configuration.openSideBySideDirection
|
||||
});
|
||||
}
|
||||
|
||||
private get configuration() {
|
||||
const editorConfig = this.configurationService.getValue<IWorkbenchEditorConfiguration>().workbench.editor;
|
||||
|
||||
return {
|
||||
openEditorPinned: !editorConfig.enablePreviewFromQuickOpen,
|
||||
openSideBySideDirection: editorConfig.openSideBySideDirection
|
||||
};
|
||||
}
|
||||
|
||||
protected get activeTextEditorControl() {
|
||||
return this.editorService.activeTextEditorControl;
|
||||
}
|
||||
|
||||
protected gotoLocation(editor: IEditor, range: IRange, keyMods: IKeyMods, forceSideBySide?: boolean): void {
|
||||
|
||||
// Check for sideBySide use
|
||||
if ((keyMods.ctrlCmd || forceSideBySide) && this.editorService.activeEditor) {
|
||||
this.editorService.openEditor(this.editorService.activeEditor, {
|
||||
selection: range,
|
||||
pinned: keyMods.alt || this.configuration.openEditorPinned
|
||||
}, SIDE_GROUP);
|
||||
}
|
||||
|
||||
// Otherwise let parent handle it
|
||||
else {
|
||||
super.gotoLocation(editor, range, keyMods);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Registry.as<IQuickAccessRegistry>(Extensions.Quickaccess).registerQuickAccessProvider({
|
||||
ctor: GotoSymbolQuickAccessProvider,
|
||||
prefix: AbstractGotoSymbolQuickAccessProvider.PREFIX,
|
||||
placeholder: localize('gotoSymbolQuickAccessPlaceholder', "Type the name of a symbol to go to."),
|
||||
helpEntries: [
|
||||
{ description: localize('gotoSymbolQuickAccess', "Go to Symbol in Editor"), prefix: AbstractGotoSymbolQuickAccessProvider.PREFIX, needsEditor: true },
|
||||
{ description: localize('gotoSymbolByCategoryQuickAccess', "Go to Symbol in Editor by Category"), prefix: AbstractGotoSymbolQuickAccessProvider.PREFIX_BY_CATEGORY, needsEditor: true }
|
||||
]
|
||||
});
|
||||
@@ -0,0 +1,86 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import * as path from 'vs/base/common/path';
|
||||
import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { registerEditorContribution } from 'vs/editor/browser/editorExtensions';
|
||||
import { IEditorContribution } from 'vs/editor/common/editorCommon';
|
||||
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
|
||||
|
||||
/**
|
||||
* Shows a message when semantic tokens are shown the first time.
|
||||
*/
|
||||
export class SemanticTokensHelp extends Disposable implements IEditorContribution {
|
||||
|
||||
public static readonly ID = 'editor.contrib.semanticHighlightHelp';
|
||||
|
||||
constructor(
|
||||
_editor: ICodeEditor,
|
||||
@INotificationService _notificationService: INotificationService,
|
||||
@IOpenerService _openerService: IOpenerService,
|
||||
@IWorkbenchThemeService _themeService: IWorkbenchThemeService
|
||||
) {
|
||||
super();
|
||||
|
||||
const toDispose = this._register(new DisposableStore());
|
||||
const localToDispose = toDispose.add(new DisposableStore());
|
||||
const installChangeTokenListener = (model: ITextModel) => {
|
||||
localToDispose.add(model.onDidChangeTokens((e) => {
|
||||
if (!e.semanticTokensApplied) {
|
||||
return;
|
||||
}
|
||||
|
||||
toDispose.dispose(); // uninstall all listeners, makes sure the notification is only shown once per window
|
||||
|
||||
const message = nls.localize(
|
||||
{
|
||||
key: 'semanticTokensHelp',
|
||||
comment: [
|
||||
'Variable 0 will be a file name.',
|
||||
'Variable 1 will be a theme name.'
|
||||
]
|
||||
},
|
||||
"Semantic highlighting has been applied to '{0}' as the theme '{1}' has semantic highlighting enabled.",
|
||||
path.basename(model.uri.path), _themeService.getColorTheme().label
|
||||
);
|
||||
|
||||
_notificationService.prompt(Severity.Info, message, [
|
||||
{
|
||||
label: nls.localize('learnMoreButton', "Learn More"),
|
||||
run: () => {
|
||||
const url = 'https://go.microsoft.com/fwlink/?linkid=2122588';
|
||||
|
||||
_openerService.open(URI.parse(url));
|
||||
}
|
||||
}
|
||||
], { neverShowAgain: { id: 'editor.contrib.semanticTokensHelp' } });
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
const model = _editor.getModel();
|
||||
if (model !== null) {
|
||||
installChangeTokenListener(model);
|
||||
}
|
||||
|
||||
toDispose.add(_editor.onDidChangeModel((e) => {
|
||||
localToDispose.clear();
|
||||
|
||||
const model = _editor.getModel();
|
||||
if (!model) {
|
||||
return;
|
||||
}
|
||||
installChangeTokenListener(model);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
registerEditorContribution(SemanticTokensHelp.ID, SemanticTokensHelp);
|
||||
Reference in New Issue
Block a user