diff --git a/src/commands/quickPickItems.ts b/src/commands/quickPickItems.ts index 4d20a24..4bd8c65 100644 --- a/src/commands/quickPickItems.ts +++ b/src/commands/quickPickItems.ts @@ -124,7 +124,7 @@ export class OpenCommitFileCommandQuickPickItem extends OpenFileCommandQuickPick item = { ...{ label: `$(file-symlink-file) Open File`, - description: `\u00a0 \u2014 \u00a0\u00a0 ${path.basename(commit.fileName)} \u00a0\u2022\u00a0 ${path.dirname(commit.fileName)}` + description: `\u00a0 \u2014 \u00a0\u00a0 ${commit.getFormattedPath()}` }, ...item }; @@ -145,10 +145,15 @@ const statusOcticons = [ export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPickItem { constructor(status: GitFileStatusItem, item?: PartialQuickPickItem) { + let directory = path.dirname(status.fileName); + if (!directory || directory === '.') { + directory = undefined; + } + item = { ...{ label: `${status.staged ? '$(check)' : '\u00a0\u00a0\u00a0'}\u00a0${statusOcticons[status.status]}\u00a0\u00a0\u00a0${path.basename(status.fileName)}`, - description: path.dirname(status.fileName) + description: directory }, ...item }; @@ -180,8 +185,14 @@ export class FileQuickPickItem implements QuickPickItem { uri: GitUri; constructor(commit: GitCommit, public fileName: string) { - this.label = path.basename(fileName); - this.description = path.dirname(fileName); + this.label = `$(info) ${path.basename(fileName)}`; + + let directory = path.dirname(fileName); + if (!directory || directory === '.') { + directory = undefined; + } + + this.description = directory; this.sha = commit.sha; this.uri = GitUri.fromUri(Uri.file(path.resolve(commit.repoPath, fileName))); diff --git a/src/commands/quickPicks.ts b/src/commands/quickPicks.ts index c49489b..8b12204 100644 --- a/src/commands/quickPicks.ts +++ b/src/commands/quickPicks.ts @@ -80,7 +80,7 @@ export class CommitQuickPick { return await window.showQuickPick(items, { matchOnDescription: true, - placeHolder: `${path.basename(commit.fileName)} \u00a0\u2022\u00a0 ${path.dirname(commit.fileName)} \u2022 ${isUncommitted ? 'Uncommitted \u21E8 ' : '' }${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`, + placeHolder: `${commit.getFormattedPath()} \u2022 ${isUncommitted ? 'Uncommitted \u21E8 ' : '' }${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`, ignoreFocusOut: getQuickPickIgnoreFocusOut() } as QuickPickOptions); } @@ -153,12 +153,12 @@ export class FileCommitsQuickPick { items.splice(0, 0, goBackCommand); } - const fileName = Iterables.first(log.commits.values()).fileName; + const commit = Iterables.first(log.commits.values()); return await window.showQuickPick(items, { matchOnDescription: true, matchOnDetail: true, - placeHolder: `${path.basename(fileName)} \u00a0\u2022\u00a0 ${path.dirname(fileName)}`, + placeHolder: commit.getFormattedPath(), ignoreFocusOut: getQuickPickIgnoreFocusOut() } as QuickPickOptions); } diff --git a/src/git/gitEnrichment.ts b/src/git/gitEnrichment.ts index cb81335..65c5a8b 100644 --- a/src/git/gitEnrichment.ts +++ b/src/git/gitEnrichment.ts @@ -92,6 +92,13 @@ export class GitCommit implements IGitCommit { get uri(): Uri { return Uri.file(path.join(this.repoPath, this.originalFileName || this.fileName)); } + + getFormattedPath(separator: string = ' \u00a0\u2022\u00a0 '): string { + const directory = path.dirname(this.fileName); + return (!directory || directory === '.') + ? path.basename(this.fileName) + : `${path.basename(this.fileName)}${separator}${directory}`; + } } export interface IGitCommitLine {