Skip to content

Commit

Permalink
file-search: fix paths
Browse files Browse the repository at this point in the history
The commit fixes the paths which are displayed during the
`quick-file-search`:

- direct child resources of a root should not have a description
- fixes root-name for multi-root workspaces
- fixes label for multi-root workspaces when they are direct child
  resources of the given root.

Signed-off-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto committed Aug 24, 2021
1 parent d3c20cd commit 863c738
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/file-search/src/browser/quick-file-open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,21 @@ export class QuickFileOpenService implements QuickAccessProvider {
}

private getItemDescription(uri: URI): string {
let description = this.labelProvider.getLongName(uri.parent);
const resourcePathLabel = this.labelProvider.getLongName(uri.parent);
const rootUri = this.workspaceService.getWorkspaceRootUri(uri);

// Display the path normally if outside any workspace root.
if (!rootUri) {
return resourcePathLabel;
}

// Compute the multi-root label for the resource.
if (this.workspaceService.isMultiRootWorkspaceOpened) {
const rootUri = this.workspaceService.getWorkspaceRootUri(uri);
if (rootUri) {
description = `${this.labelProvider.getLongName(rootUri)}${description}`;
}
const rootLabel = this.labelProvider.getName(rootUri);
return rootUri.path.toString() === uri.parent.path.toString() ? `${rootLabel}` : `${rootLabel}${resourcePathLabel}`;
} else {
return rootUri.toString() === uri.parent.toString() ? '' : resourcePathLabel;
}
return description;
}

private getPlaceHolder(): string {
Expand Down

0 comments on commit 863c738

Please sign in to comment.