提交 f31af7f9 编写于 作者: B Benjamin Pasero

quick access - also show no-result pick for editor symbols

上级 4681c1cc
...@@ -42,10 +42,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit ...@@ -42,10 +42,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
} }
protected provideWithoutTextEditor(picker: IQuickPick<IGotoSymbolQuickPickItem>): IDisposable { protected provideWithoutTextEditor(picker: IQuickPick<IGotoSymbolQuickPickItem>): IDisposable {
const label = localize('cannotRunGotoSymbolWithoutEditor', "To go to a symbol, first open a text editor with symbol information."); this.provideLabelPick(picker, localize('cannotRunGotoSymbolWithoutEditor', "To go to a symbol, first open a text editor with symbol information."));
picker.items = [{ label, index: 0, kind: SymbolKind.String }];
picker.ariaLabel = label;
return Disposable.None; return Disposable.None;
} }
...@@ -71,9 +68,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit ...@@ -71,9 +68,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
const disposables = new DisposableStore(); const disposables = new DisposableStore();
// Generic pick for not having any symbol information // Generic pick for not having any symbol information
const label = localize('cannotRunGotoSymbolWithoutSymbolProvider', "The active text editor does not provide symbol information."); this.provideLabelPick(picker, localize('cannotRunGotoSymbolWithoutSymbolProvider', "The active text editor does not provide symbol information."));
picker.items = [{ label, index: 0, kind: SymbolKind.String }];
picker.ariaLabel = label;
// Wait for changes to the registry and see if eventually // Wait for changes to the registry and see if eventually
// we do get symbols. This can happen if the picker is opened // we do get symbols. This can happen if the picker is opened
...@@ -92,6 +87,11 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit ...@@ -92,6 +87,11 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
return disposables; return disposables;
} }
private provideLabelPick(picker: IQuickPick<IGotoSymbolQuickPickItem>, label: string): void {
picker.items = [{ label, index: 0, kind: SymbolKind.String }];
picker.ariaLabel = label;
}
protected async waitForLanguageSymbolRegistry(model: ITextModel, disposables: DisposableStore): Promise<boolean> { protected async waitForLanguageSymbolRegistry(model: ITextModel, disposables: DisposableStore): Promise<boolean> {
if (DocumentSymbolProviderRegistry.has(model)) { if (DocumentSymbolProviderRegistry.has(model)) {
return true; return true;
...@@ -157,12 +157,21 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit ...@@ -157,12 +157,21 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
// Collect symbol picks // Collect symbol picks
picker.busy = true; picker.busy = true;
try { try {
const items = await this.doGetSymbolPicks(symbolsPromise, prepareQuery(picker.value.substr(AbstractGotoSymbolQuickAccessProvider.PREFIX.length).trim()), undefined, picksCts.token); const query = prepareQuery(picker.value.substr(AbstractGotoSymbolQuickAccessProvider.PREFIX.length).trim());
const items = await this.doGetSymbolPicks(symbolsPromise, query, undefined, picksCts.token);
if (token.isCancellationRequested) { if (token.isCancellationRequested) {
return; return;
} }
picker.items = items; if (items.length > 0) {
picker.items = items;
} else {
if (query.original.length > 0) {
this.provideLabelPick(picker, localize('noMatchingSymbolResults', "No matching editor symbols"));
} else {
this.provideLabelPick(picker, localize('noSymbolResults', "No editor symbols"));
}
}
} finally { } finally {
if (!token.isCancellationRequested) { if (!token.isCancellationRequested) {
picker.busy = false; picker.busy = false;
...@@ -359,7 +368,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit ...@@ -359,7 +368,7 @@ export abstract class AbstractGotoSymbolQuickAccessProvider extends AbstractEdit
// Update last separator with number of symbols we found for kind // Update last separator with number of symbols we found for kind
updateLastSeparatorLabel(); updateLastSeparatorLabel();
} else { } else if (sortedFilteredSymbolPicks.length > 0) {
symbolPicks = [ symbolPicks = [
{ label: localize('symbols', "symbols ({0})", filteredSymbolPicks.length), type: 'separator' }, { label: localize('symbols', "symbols ({0})", filteredSymbolPicks.length), type: 'separator' },
...sortedFilteredSymbolPicks ...sortedFilteredSymbolPicks
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册