Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973 (#6381)

* Merge from vscode 8e0f348413f4f616c23a88ae30030efa85811973

* disable strict null check
This commit is contained in:
Anthony Dresser
2019-07-15 22:35:46 -07:00
committed by GitHub
parent f720ec642f
commit 0b7e7ddbf9
2406 changed files with 59140 additions and 35464 deletions

View File

@@ -7,7 +7,7 @@ import * as nls from 'vs/nls';
import * as arrays from 'vs/base/common/arrays';
import * as types from 'vs/base/common/types';
import { Language } from 'vs/base/common/platform';
import { Action } from 'vs/base/common/actions';
import { Action, WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification } from 'vs/base/common/actions';
import { Mode, IEntryRunContext, IAutoFocus, IModel, IQuickNavigateConfiguration } from 'vs/base/parts/quickopen/common/quickOpen';
import { QuickOpenEntryGroup, IHighlight, QuickOpenModel, QuickOpenEntry } from 'vs/base/parts/quickopen/browser/quickOpenModel';
import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
@@ -30,7 +30,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { Disposable } from 'vs/base/common/lifecycle';
import { Disposable, DisposableStore, IDisposable, toDisposable, dispose } from 'vs/base/common/lifecycle';
import { timeout } from 'vs/base/common/async';
export const ALL_COMMANDS_PREFIX = '>';
@@ -78,14 +78,15 @@ class CommandsHistory extends Disposable {
private registerListeners(): void {
this._register(this.configurationService.onDidChangeConfiguration(e => this.updateConfiguration()));
this._register(this.storageService.onWillSaveState(() => this.saveState()));
}
private updateConfiguration(): void {
this.commandHistoryLength = resolveCommandHistory(this.configurationService);
if (commandHistory) {
if (commandHistory && commandHistory.limit !== this.commandHistoryLength) {
commandHistory.limit = this.commandHistoryLength;
CommandsHistory.saveState(this.storageService);
}
}
@@ -116,18 +117,20 @@ class CommandsHistory extends Disposable {
push(commandId: string): void {
commandHistory.set(commandId, commandCounter++); // set counter to command
CommandsHistory.saveState(this.storageService);
}
peek(commandId: string): number | undefined {
return commandHistory.peek(commandId);
}
private saveState(): void {
static saveState(storageService: IStorageService): void {
const serializedCache: ISerializedCommandHistory = { usesLRU: true, entries: [] };
commandHistory.forEach((value, key) => serializedCache.entries.push({ key, value }));
this.storageService.store(CommandsHistory.PREF_KEY_CACHE, JSON.stringify(serializedCache), StorageScope.GLOBAL);
this.storageService.store(CommandsHistory.PREF_KEY_COUNTER, commandCounter, StorageScope.GLOBAL);
storageService.store(CommandsHistory.PREF_KEY_CACHE, JSON.stringify(serializedCache), StorageScope.GLOBAL);
storageService.store(CommandsHistory.PREF_KEY_COUNTER, commandCounter, StorageScope.GLOBAL);
}
}
@@ -169,7 +172,8 @@ export class ClearCommandHistoryAction extends Action {
constructor(
id: string,
label: string,
@IConfigurationService private readonly configurationService: IConfigurationService
@IConfigurationService private readonly configurationService: IConfigurationService,
@IStorageService private readonly storageService: IStorageService
) {
super(id, label);
}
@@ -179,6 +183,8 @@ export class ClearCommandHistoryAction extends Action {
if (commandHistoryLength > 0) {
commandHistory = new LRUCache<string, number>(commandHistoryLength);
commandCounter = 1;
CommandsHistory.saveState(this.storageService);
}
return Promise.resolve(undefined);
@@ -294,21 +300,21 @@ abstract class BaseCommandEntry extends QuickOpenEntryGroup {
this.onBeforeRun(this.commandId);
// Use a timeout to give the quick open widget a chance to close itself first
setTimeout(() => {
setTimeout(async () => {
if (action && (!(action instanceof Action) || action.enabled)) {
try {
/* __GDPR__
"workbenchActionExecuted" : {
"id" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"from": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
this.telemetryService.publicLog2<WorkbenchActionExecutedEvent, WorkbenchActionExecutedClassification>('workbenchActionExecuted', { id: action.id, from: 'quick open' });
const promise = action.run();
if (promise) {
try {
await promise;
} finally {
if (action instanceof Action) {
action.dispose();
}
}
*/
this.telemetryService.publicLog('workbenchActionExecuted', { id: action.id, from: 'quick open' });
(action.run() || Promise.resolve()).then(() => {
if (action instanceof Action) {
action.dispose();
}
}, err => this.onError(err));
}
} catch (error) {
this.onError(error);
}
@@ -371,12 +377,15 @@ class ActionCommandEntry extends BaseCommandEntry {
const wordFilter = or(matchesPrefix, matchesWords, matchesContiguousSubString);
export class CommandsHandler extends QuickOpenHandler {
export class CommandsHandler extends QuickOpenHandler implements IDisposable {
static readonly ID = 'workbench.picker.commands';
private commandHistoryEnabled: boolean;
private commandsHistory: CommandsHistory;
private readonly commandsHistory: CommandsHistory;
private readonly disposables = new DisposableStore();
private readonly disposeOnClose = new DisposableStore();
private waitedForExtensionsRegistered: boolean;
@@ -390,7 +399,7 @@ export class CommandsHandler extends QuickOpenHandler {
) {
super();
this.commandsHistory = this.instantiationService.createInstance(CommandsHistory);
this.commandsHistory = this.disposables.add(this.instantiationService.createInstance(CommandsHistory));
this.extensionService.whenInstalledExtensionsRegistered().then(() => this.waitedForExtensionsRegistered = true);
@@ -402,7 +411,7 @@ export class CommandsHandler extends QuickOpenHandler {
this.commandHistoryEnabled = resolveCommandHistory(this.configurationService) > 0;
}
getResults(searchValue: string, token: CancellationToken): Promise<QuickOpenModel> {
async getResults(searchValue: string, token: CancellationToken): Promise<QuickOpenModel> {
if (this.waitedForExtensionsRegistered) {
return this.doGetResults(searchValue, token);
}
@@ -411,11 +420,10 @@ export class CommandsHandler extends QuickOpenHandler {
// a chance to register so that the complete set of commands shows up as result
// We do not want to delay functionality beyond that time though to keep the commands
// functional.
return Promise.race([timeout(800), this.extensionService.whenInstalledExtensionsRegistered().then(() => undefined)]).then(() => {
this.waitedForExtensionsRegistered = true;
await Promise.race([timeout(800).then(), this.extensionService.whenInstalledExtensionsRegistered()]);
this.waitedForExtensionsRegistered = true;
return this.doGetResults(searchValue, token);
});
return this.doGetResults(searchValue, token);
}
private doGetResults(searchValue: string, token: CancellationToken): Promise<QuickOpenModel> {
@@ -442,6 +450,7 @@ export class CommandsHandler extends QuickOpenHandler {
const menuActions = menu.getActions().reduce((r, [, actions]) => [...r, ...actions], <MenuItemAction[]>[]).filter(action => action instanceof MenuItemAction) as MenuItemAction[];
const commandEntries = this.menuItemActionsToEntries(menuActions, searchValue);
menu.dispose();
this.disposeOnClose.add(toDisposable(() => dispose(menuActions)));
// Concat
let entries = [...editorEntries, ...commandEntries];
@@ -583,6 +592,17 @@ export class CommandsHandler extends QuickOpenHandler {
getEmptyLabel(searchString: string): string {
return nls.localize('noCommandsMatching', "No commands matching");
}
onClose(canceled: boolean): void {
super.onClose(canceled);
this.disposeOnClose.clear();
}
dispose() {
this.disposables.dispose();
this.disposeOnClose.dispose();
}
}
registerEditorAction(CommandPaletteEditorAction);

View File

@@ -495,7 +495,7 @@ export class GotoSymbolHandler extends QuickOpenHandler {
return this.cachedOutlineRequest;
}
private doGetActiveOutline(): Promise<OutlineModel | null> {
private async doGetActiveOutline(): Promise<OutlineModel | null> {
const activeTextEditorWidget = this.editorService.activeTextEditorWidget;
if (activeTextEditorWidget) {
let model = activeTextEditorWidget.getModel();
@@ -504,13 +504,13 @@ export class GotoSymbolHandler extends QuickOpenHandler {
}
if (model && types.isFunction((<ITextModel>model).getLanguageIdentifier)) {
return Promise.resolve(asPromise(() => getDocumentSymbols(<ITextModel>model, true, this.pendingOutlineRequest!.token)).then(entries => {
return new OutlineModel(this.toQuickOpenEntries(entries));
}));
const entries = await asPromise(() => getDocumentSymbols(<ITextModel>model, true, this.pendingOutlineRequest!.token));
return new OutlineModel(this.toQuickOpenEntries(entries));
}
}
return Promise.resolve(null);
return null;
}
decorateOutline(fullRange: IRange, startRange: IRange, editor: IEditor, group: IEditorGroup): void {

View File

@@ -184,4 +184,13 @@ MenuRegistry.appendMenuItem(MenuId.MenubarGoMenu, {
title: nls.localize({ key: 'miGotoLine', comment: ['&& denotes a mnemonic'] }, "Go to &&Line/Column...")
},
order: 1
});
MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
group: '1_command',
command: {
id: ShowAllCommandsAction.ID,
title: nls.localize('commandPalette', "Command Palette...")
},
order: 1
});

View File

@@ -21,6 +21,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { ViewletDescriptor } from 'vs/workbench/browser/viewlet';
import { Registry } from 'vs/platform/registry/common/platform';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IStringDictionary } from 'vs/base/common/collections';
export const VIEW_PICKER_PREFIX = 'view ';
@@ -101,7 +102,7 @@ export class ViewPickerHandler extends QuickOpenHandler {
return true;
});
const entryToCategory = {};
const entryToCategory: IStringDictionary<string> = {};
entries.forEach(e => {
if (!entryToCategory[e.getLabel()]) {
entryToCategory[e.getLabel()] = e.getCategory();