瀏覽代碼

Adds file context to commit file quick pick

main
Eric Amodio 4 年之前
父節點
當前提交
b7394c9013
共有 2 個檔案被更改,包括 8 行新增3 行删除
  1. +3
    -1
      src/commands/quickCommand.steps.ts
  2. +5
    -2
      src/quickpicks/commitQuickPickItems.ts

+ 3
- 1
src/commands/quickCommand.steps.ts 查看文件

@ -1703,7 +1703,9 @@ async function getShowCommitOrStashFileStepItems<
const file = state.reference.files.find(f => f.fileName === state.fileName);
if (file == null) return [];
const items: CommandQuickPickItem[] = [new CommitFilesQuickPickItem(state.reference)];
const items: CommandQuickPickItem[] = [
new CommitFilesQuickPickItem(state.reference, undefined, GitUri.getFormattedFilename(state.fileName)),
];
let remotes: GitRemote<RemoteProvider>[] | undefined;

+ 5
- 2
src/quickpicks/commitQuickPickItems.ts 查看文件

@ -2,6 +2,7 @@
import * as paths from 'path';
import { QuickPickItem, window } from 'vscode';
import { Commands, GitActions, OpenChangedFilesCommandArgs } from '../commands';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { CommitFormatter, GitFile, GitLogCommit, GitStatusFile } from '../git/git';
import { Keys } from '../keyboard';
@ -9,13 +10,15 @@ import { CommandQuickPickItem } from './quickPicksItems';
import { Strings } from '../system';
export class CommitFilesQuickPickItem extends CommandQuickPickItem {
constructor(readonly commit: GitLogCommit, picked: boolean = true) {
constructor(readonly commit: GitLogCommit, picked: boolean = true, fileName?: string) {
super(
{
label: commit.getShortMessage(),
// eslint-disable-next-line no-template-curly-in-string
description: CommitFormatter.fromTemplate('${author}, ${ago} $(git-commit) ${id}', commit),
detail: `$(files) ${commit.getFormattedDiffStatus({ expand: true, separator: ', ' })}`,
detail: `$(files) ${commit.getFormattedDiffStatus({ expand: true, separator: ', ' })}${
fileName ? `${Strings.pad(GlyphChars.Dot, 2, 2)}${fileName}` : ''
}`,
picked: picked,
},
undefined,

Loading…
取消
儲存