Always Show File Names in Symbol Search Results (#26518)

* Fixes #26370

Updates the symbol search results to always display the filename. This feature was previously added to the TS extension specifically, so this change removes that work in favor of a change to the core symbol search experience

* Use dash with filename
This commit is contained in:
Matt Bierner 2017-05-16 17:00:43 -07:00 committed by GitHub
parent 405271c17d
commit 17004573e3
3 changed files with 12 additions and 18 deletions

View file

@ -7,8 +7,6 @@
import { workspace, window, Uri, WorkspaceSymbolProvider, SymbolInformation, SymbolKind, Range, Location, CancellationToken } from 'vscode';
import * as path from 'path';
import * as Proto from '../protocol';
import { ITypescriptServiceClient } from '../typescriptService';
@ -76,17 +74,8 @@ export default class TypeScriptWorkspaceSymbolProvider implements WorkspaceSymbo
if (item.kind === 'method' || item.kind === 'function') {
label += '()';
}
const containerNameParts: string[] = [];
if (item.containerName) {
containerNameParts.push(item.containerName);
}
const fileUri = this.client.asUrl(item.file);
const fileName = path.basename(fileUri.fsPath);
if (fileName) {
containerNameParts.push(fileName);
}
result.push(new SymbolInformation(label, getSymbolKind(item), containerNameParts.join(' — '),
new Location(fileUri, range)));
result.push(new SymbolInformation(label, getSymbolKind(item), item.containerName || '',
new Location(this.client.asUrl(item.file), range)));
}
}
return result;

View file

@ -288,7 +288,7 @@ export class EditorQuickOpenEntry extends QuickOpenEntry implements IEditorQuick
*/
export class EditorQuickOpenEntryGroup extends QuickOpenEntryGroup implements IEditorQuickOpenEntry {
public getInput(): IEditorInput {
public getInput(): IEditorInput | IResourceInput {
return null;
}

View file

@ -25,6 +25,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWorkspaceSymbolProvider, getWorkspaceSymbols } from 'vs/workbench/parts/search/common/search';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { basename } from 'vs/base/common/paths';
class SymbolEntry extends EditorQuickOpenEntry {
@ -50,11 +51,15 @@ class SymbolEntry extends EditorQuickOpenEntry {
}
public getDescription(): string {
let result = this._bearing.containerName;
if (!result && this._bearing.location.uri) {
result = labels.getPathLabel(this._bearing.location.uri, this._contextService, this._environmentService);
const containerName = this._bearing.containerName;
if (this._bearing.location.uri) {
if (containerName) {
return `${containerName}${basename(this._bearing.location.uri.fsPath)}`;
} else {
return labels.getPathLabel(this._bearing.location.uri, this._contextService, this._environmentService);
}
}
return result;
return containerName;
}
public getIcon(): string {