Merge from vscode 27ada910e121e23a6d95ecca9cae595fb98ab568

This commit is contained in:
ADS Merger
2020-04-30 00:53:43 +00:00
parent 87e5239713
commit 93f35ca321
413 changed files with 7190 additions and 8756 deletions

View File

@@ -32,6 +32,7 @@
.tiw-metadata-value {
font-family: var(--monaco-monospace-font);
text-align: right;
word-break: break-word;
}
.tiw-metadata-key {
vertical-align: top;

View File

@@ -27,7 +27,7 @@ import { ITextMateService, IGrammar, IToken, StackElement } from 'vs/workbench/s
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { ColorThemeData, TokenStyleDefinitions, TokenStyleDefinition, TextMateThemingRuleDefinitions } from 'vs/workbench/services/themes/common/colorThemeData';
import { TokenStylingRule, TokenStyleData, TokenStyle } from 'vs/platform/theme/common/tokenClassificationRegistry';
import { SemanticTokenRule, TokenStyleData, TokenStyle } from 'vs/platform/theme/common/tokenClassificationRegistry';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
export interface IEditorSemanticHighlightingOptions {
@@ -251,6 +251,7 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
}
let text = this._compute(grammar, semanticTokens, position);
this._domNode.innerHTML = text;
this._domNode.style.maxWidth = `${Math.max(this._editor.getLayoutInfo().width * 0.66, 500)}px`;
this._editor.layoutContentWidget(this);
}, (err) => {
this._notificationService.warn(err);
@@ -552,10 +553,11 @@ class InspectEditorTokensWidget extends Disposable implements IContentWidget {
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>`;
const strScopes = Array.isArray(matchingRule.scope) ? matchingRule.scope.join(', ') : String(matchingRule.scope);
return `${escape(scopesDefinition.scope.join(' '))}<br><code class="tiw-theme-selector">${strScopes}\n${JSON.stringify(matchingRule.settings, null, '\t')}</code>`;
}
return '';
} else if (TokenStylingRule.is(definition)) {
} else if (SemanticTokenRule.is(definition)) {
const scope = theme.getTokenStylingRuleScope(definition);
if (scope === 'setting') {
return `User settings: ${definition.selector.id} - ${this._renderStyleProperty(definition.style, property)}`;

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { localize } from 'vs/nls';
import { IKeyMods, IQuickPickSeparator, IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { IKeyMods, IQuickPickSeparator, IQuickInputService, IQuickPick } 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';
@@ -12,16 +12,19 @@ import { Registry } from 'vs/platform/registry/common/platform';
import { IQuickAccessRegistry, Extensions as QuickaccessExtensions } from 'vs/platform/quickinput/common/quickAccess';
import { AbstractGotoSymbolQuickAccessProvider, IGotoSymbolQuickPickItem } from 'vs/editor/contrib/quickAccess/gotoSymbolQuickAccess';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkbenchEditorConfiguration } from 'vs/workbench/common/editor';
import { IWorkbenchEditorConfiguration, IEditorPane } from 'vs/workbench/common/editor';
import { ITextModel } from 'vs/editor/common/model';
import { DisposableStore } from 'vs/base/common/lifecycle';
import { DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { timeout } from 'vs/base/common/async';
import { CancellationToken } from 'vs/base/common/cancellation';
import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation';
import { Action } from 'vs/base/common/actions';
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { prepareQuery } from 'vs/base/common/fuzzyScorer';
import { SymbolKind } from 'vs/editor/common/modes';
import { fuzzyScore, createMatches } from 'vs/base/common/filters';
import { onUnexpectedError } from 'vs/base/common/errors';
export class GotoSymbolQuickAccessProvider extends AbstractGotoSymbolQuickAccessProvider {
@@ -36,6 +39,8 @@ export class GotoSymbolQuickAccessProvider extends AbstractGotoSymbolQuickAccess
});
}
//#region DocumentSymbols (text editor required)
private get configuration() {
const editorConfig = this.configurationService.getValue<IWorkbenchEditorConfiguration>().workbench.editor;
@@ -66,6 +71,7 @@ export class GotoSymbolQuickAccessProvider extends AbstractGotoSymbolQuickAccess
}
}
//#endregion
//#region public methods to use this picker from other pickers
@@ -98,6 +104,81 @@ export class GotoSymbolQuickAccessProvider extends AbstractGotoSymbolQuickAccess
}
//#endregion
protected provideWithoutTextEditor(picker: IQuickPick<IGotoSymbolQuickPickItem>): IDisposable {
const pane = this.editorService.activeEditorPane;
if (!pane || !TableOfContentsProviderRegistry.has(pane.getId())) {
//
return super.provideWithoutTextEditor(picker);
}
const provider = TableOfContentsProviderRegistry.get(pane.getId())!;
const cts = new CancellationTokenSource();
const disposables = new DisposableStore();
disposables.add(toDisposable(() => cts.dispose(true)));
picker.busy = true;
provider.provideTableOfContents(pane, cts.token).then(entries => {
picker.busy = false;
if (cts.token.isCancellationRequested || !entries || entries.length === 0) {
return;
}
const items: IGotoSymbolQuickPickItem[] = entries.map((entry, idx) => {
return {
kind: SymbolKind.File,
index: idx,
score: 0,
label: entry.label,
detail: entry.detail,
description: entry.description,
};
});
disposables.add(picker.onDidAccept(() => {
picker.hide();
const [entry] = picker.selectedItems;
entries[entry.index]?.reveal();
}));
const updatePickerItems = () => {
const filteredItems = items.filter(item => {
if (picker.value === '@') {
// default, no filtering, scoring...
item.score = 0;
item.highlights = undefined;
return true;
}
const score = fuzzyScore(picker.value, picker.value.toLowerCase(), 1 /*@-character*/, item.label, item.label.toLowerCase(), 0, true);
if (!score) {
return false;
}
item.score = score[1];
item.highlights = { label: createMatches(score) };
return true;
});
if (filteredItems.length === 0) {
const label = localize('empty', 'No matching entries');
picker.items = [{ label, index: -1, kind: SymbolKind.String }];
picker.ariaLabel = label;
} else {
picker.items = filteredItems;
}
};
updatePickerItems();
disposables.add(picker.onDidChangeValue(updatePickerItems));
}).catch(err => {
onUnexpectedError(err);
picker.hide();
});
return disposables;
}
}
Registry.as<IQuickAccessRegistry>(QuickaccessExtensions.Quickaccess).registerQuickAccessProvider({
@@ -132,3 +213,43 @@ export class GotoSymbolAction extends Action {
Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions).registerWorkbenchAction(SyncActionDescriptor.from(GotoSymbolAction, {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_O
}), 'Go to Symbol in Editor...');
//#region toc definition and logic
export interface ITableOfContentsEntry {
label: string;
detail?: string;
description?: string;
reveal(): any;
}
export interface ITableOfContentsProvider<T extends IEditorPane = IEditorPane> {
provideTableOfContents(editor: T, token: CancellationToken): Promise<ITableOfContentsEntry[] | undefined | null>;
}
class ProviderRegistry {
private readonly _provider = new Map<string, ITableOfContentsProvider>();
register(type: string, provider: ITableOfContentsProvider): IDisposable {
this._provider.set(type, provider);
return toDisposable(() => {
if (this._provider.get(type) === provider) {
this._provider.delete(type);
}
});
}
get(type: string): ITableOfContentsProvider | undefined {
return this._provider.get(type);
}
has(type: string): boolean {
return this._provider.has(type);
}
}
export const TableOfContentsProviderRegistry = new ProviderRegistry();
//#endregion

View File

@@ -6,3 +6,4 @@
import './inputClipboardActions';
import './sleepResumeRepaintMinimap';
import './selectionClipboard';
import './startDebugTextMate';

View File

@@ -0,0 +1,107 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as os from 'os';
import * as path from 'path';
import * as nls from 'vs/nls';
import { Range } from 'vs/editor/common/core/range';
import { Action } from 'vs/base/common/actions';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { Registry } from 'vs/platform/registry/common/platform';
import { Extensions as ActionExtensions, IWorkbenchActionRegistry } from 'vs/workbench/common/actions';
import { ITextMateService } from 'vs/workbench/services/textMate/common/textMateService';
import { IModelService } from 'vs/editor/common/services/modelService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { URI } from 'vs/base/common/uri';
import { createRotatingLogger } from 'vs/platform/log/node/spdlogService';
import { generateUuid } from 'vs/base/common/uuid';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { ITextModel } from 'vs/editor/common/model';
import { Constants } from 'vs/base/common/uint';
import { IHostService } from 'vs/workbench/services/host/browser/host';
class StartDebugTextMate extends Action {
private static resource = URI.parse(`inmemory:///tm-log.txt`);
public static readonly ID = 'editor.action.startDebugTextMate';
public static readonly LABEL = nls.localize('startDebugTextMate', "Start Text Mate Syntax Grammar Logging");
constructor(
id: string,
label: string,
@ITextMateService private readonly _textMateService: ITextMateService,
@IModelService private readonly _modelService: IModelService,
@IEditorService private readonly _editorService: IEditorService,
@ICodeEditorService private readonly _codeEditorService: ICodeEditorService,
@IHostService private readonly _hostService: IHostService
) {
super(id, label);
}
private _getOrCreateModel(): ITextModel {
const model = this._modelService.getModel(StartDebugTextMate.resource);
if (model) {
return model;
}
return this._modelService.createModel('', null, StartDebugTextMate.resource);
}
private _append(model: ITextModel, str: string) {
const lineCount = model.getLineCount();
model.applyEdits([{
range: new Range(lineCount, Constants.MAX_SAFE_SMALL_INTEGER, lineCount, Constants.MAX_SAFE_SMALL_INTEGER),
text: str
}]);
}
public async run(): Promise<any> {
const pathInTemp = path.join(os.tmpdir(), `vcode-tm-log-${generateUuid()}.txt`);
const logger = createRotatingLogger(`tm-log`, pathInTemp, 1024 * 1024 * 30, 1);
const model = this._getOrCreateModel();
const append = (str: string) => {
this._append(model, str + '\n');
scrollEditor();
logger.info(str);
logger.flush();
};
await this._hostService.openWindow([{ fileUri: URI.file(pathInTemp) }], { forceNewWindow: true });
const textEditorPane = await this._editorService.openEditor({
resource: model.uri
});
if (!textEditorPane) {
return;
}
const scrollEditor = () => {
const editors = this._codeEditorService.listCodeEditors();
for (const editor of editors) {
if (editor.hasModel()) {
if (editor.getModel().uri.toString() === StartDebugTextMate.resource.toString()) {
editor.revealLine(editor.getModel().getLineCount());
}
}
}
};
append(`// Open the file you want to test to the side and watch here`);
append(`// Output mirrored at ${pathInTemp}`);
this._textMateService.startDebugMode(
(str) => {
this._append(model, str + '\n');
scrollEditor();
logger.info(str);
logger.flush();
},
() => {
}
);
}
}
const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
registry.registerWorkbenchAction(SyncActionDescriptor.from(StartDebugTextMate), 'Start Text Mate Syntax Grammar Logging', nls.localize('developer', "Developer"));