瀏覽代碼

Changes to only add checkmarks when it makes sense

main
Eric Amodio 5 年之前
父節點
當前提交
33acce6f52
共有 13 個檔案被更改,包括 59 行新增22 行删除
  1. +7
    -1
      src/commands/diffBranchWith.ts
  2. +1
    -1
      src/commands/diffDirectory.ts
  3. +1
    -0
      src/commands/diffWithRef.ts
  4. +1
    -0
      src/commands/openBranchInRemote.ts
  5. +1
    -0
      src/commands/openFileInRemote.ts
  6. +2
    -1
      src/commands/openFileRevisionFrom.ts
  7. +1
    -0
      src/commands/showQuickBranchHistory.ts
  8. +1
    -0
      src/quickpicks/commonQuickPicks.ts
  9. +25
    -9
      src/quickpicks/referencesQuickPick.ts
  10. +7
    -6
      src/views/nodes/compareBranchNode.ts
  11. +8
    -2
      src/views/nodes/compareNode.ts
  12. +2
    -1
      src/views/nodes/fileHistoryTrackerNode.ts
  13. +2
    -1
      src/views/nodes/lineHistoryTrackerNode.ts

+ 7
- 1
src/commands/diffBranchWith.ts 查看文件

@ -60,21 +60,27 @@ export class DiffBranchWithCommand extends ActiveEditorCommand {
if (!repoPath) return undefined;
if (!args.ref1) {
let checkmarks;
let placeHolder;
switch (args.ref2) {
case '':
checkmarks = false;
placeHolder = `Compare Working Tree with${GlyphChars.Ellipsis}`;
break;
case 'HEAD':
checkmarks = false;
placeHolder = `Compare HEAD with${GlyphChars.Ellipsis}`;
break;
default:
checkmarks = true;
placeHolder = `Compare ${args.ref2} with${GlyphChars.Ellipsis}`;
break;
}
const pick = await new ReferencesQuickPick(repoPath).show(placeHolder, {
allowEnteringRefs: true
allowEnteringRefs: true,
checked: args.ref2,
checkmarks: checkmarks
});
if (pick === undefined) return undefined;

+ 1
- 1
src/commands/diffDirectory.ts 查看文件

@ -73,7 +73,7 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
const pick = await new ReferencesQuickPick(repoPath).show(
`Compare Working Tree with${GlyphChars.Ellipsis}`,
{ allowEnteringRefs: true }
{ allowEnteringRefs: true, checkmarks: false }
);
if (pick === undefined) return undefined;

+ 1
- 0
src/commands/diffWithRef.ts 查看文件

@ -39,6 +39,7 @@ export class DiffWithRefCommand extends ActiveEditorCommand {
`Compare ${paths.basename(gitUri.fsPath)} with${GlyphChars.Ellipsis}`,
{
allowEnteringRefs: true,
checkmarks: false,
goBack: args.goBackCommand
}
);

+ 1
- 0
src/commands/openBranchInRemote.ts 查看文件

@ -57,6 +57,7 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
`Open which branch on remote${GlyphChars.Ellipsis}`,
{
autoPick: true,
checkmarks: false,
filters: {
branches: b => b.tracking !== undefined
},

+ 1
- 0
src/commands/openFileInRemote.ts 查看文件

@ -86,6 +86,7 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
: `Open ${gitUri.relativePath} on remote for which branch${GlyphChars.Ellipsis}`,
{
autoPick: true,
checkmarks: false,
filters: {
branches: b => b.tracking !== undefined
},

+ 2
- 1
src/commands/openFileRevisionFrom.ts 查看文件

@ -32,7 +32,8 @@ export class OpenFileRevisionFromCommand extends ActiveEditorCommand {
} from${GlyphChars.Ellipsis}`;
const pick = await new ReferencesQuickPick(gitUri.repoPath).show(placeHolder, {
allowEnteringRefs: true
allowEnteringRefs: true,
checkmarks: false
});
if (pick === undefined) return undefined;
if (pick instanceof CommandQuickPickItem) return pick.execute();

+ 1
- 0
src/commands/showQuickBranchHistory.ts 查看文件

@ -61,6 +61,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
const pick = await new ReferencesQuickPick(repoPath).show(
`Show history for branch${GlyphChars.Ellipsis}`,
{
checkmarks: false,
goBack: goBackCommand,
include: 'branches'
}

+ 1
- 0
src/quickpicks/commonQuickPicks.ts 查看文件

@ -198,6 +198,7 @@ export class ShowFileHistoryFromQuickPickItem extends CommandQuickPickItem {
execute(): Promise<CommandQuickPickItem | ReferencesQuickPickItem | undefined> {
return new ReferencesQuickPick(this.repoPath).show(this.placeHolder, {
allowEnteringRefs: true,
checkmarks: false,
goBack: this._goBack
});
}

+ 25
- 9
src/quickpicks/referencesQuickPick.ts 查看文件

@ -37,9 +37,11 @@ export class BranchQuickPickItem implements QuickPickItem {
description: string;
detail: string | undefined;
constructor(public readonly branch: GitBranch, checked?: boolean) {
checked = checked || (checked === undefined && branch.current);
this.label = `${checked ? `$(check)${GlyphChars.Space}` : GlyphChars.Space.repeat(4)} ${branch.name}`;
constructor(public readonly branch: GitBranch, showCheckmarks: boolean, checked: boolean | undefined) {
checked = showCheckmarks && (checked || (checked === undefined && branch.current));
this.label = `${
checked ? `$(check)${GlyphChars.Space.repeat(2)}` : showCheckmarks ? GlyphChars.Space.repeat(6) : ''
}${branch.name}`;
this.description = branch.remote
? `${GlyphChars.Space.repeat(2)} remote branch`
: branch.current
@ -69,8 +71,11 @@ export class TagQuickPickItem implements QuickPickItem {
description: string;
detail: string | undefined;
constructor(public readonly tag: GitTag, checked?: boolean) {
this.label = `${checked ? `$(check)${GlyphChars.Space}` : GlyphChars.Space.repeat(4)} ${tag.name}`;
constructor(public readonly tag: GitTag, showCheckmarks: boolean, checked: boolean) {
checked = showCheckmarks && checked;
this.label = `${
checked ? `$(check)${GlyphChars.Space.repeat(2)}` : showCheckmarks ? GlyphChars.Space.repeat(6) : ''
}${tag.name}`;
this.description = `${GlyphChars.Space.repeat(2)} tag`;
}
@ -97,6 +102,7 @@ export interface ReferencesQuickPickOptions {
allowEnteringRefs?: boolean;
autoPick?: boolean;
checked?: string;
checkmarks: boolean;
filters?: {
branches?(branch: GitBranch): boolean;
tags?(tag: GitTag): boolean;
@ -110,7 +116,7 @@ export class ReferencesQuickPick {
async show(
placeHolder: string,
options: ReferencesQuickPickOptions = {}
options: ReferencesQuickPickOptions = { checkmarks: true }
): Promise<ReferencesQuickPickItem | CommandQuickPickItem | undefined> {
const cancellation = new CancellationTokenSource();
@ -211,7 +217,7 @@ export class ReferencesQuickPick {
}
private async getItems(options: ReferencesQuickPickOptions, token: CancellationToken) {
const { checked, filters, goBack, include } = { include: 'all', ...options };
const { checked, checkmarks, filters, goBack, include } = { include: 'all', ...options };
let branches;
let tags;
@ -257,7 +263,12 @@ export class ReferencesQuickPick {
for (const b of branches) {
if (filter !== undefined && !filter(b)) continue;
items.push(new BranchQuickPickItem(b, checked !== undefined ? b.name === checked : undefined));
if (checkmarks && checked !== undefined && b.name === checked) {
items.splice(0, 0, new BranchQuickPickItem(b, checkmarks, true));
}
else {
items.push(new BranchQuickPickItem(b, checkmarks, checked === undefined ? undefined : false));
}
}
}
@ -268,7 +279,12 @@ export class ReferencesQuickPick {
for (const t of tags) {
if (filter !== undefined && !filter(t)) continue;
items.push(new TagQuickPickItem(t, checked !== undefined ? t.name === checked : undefined));
if (checkmarks && checked !== undefined && t.name === checked) {
items.splice(0, 0, new TagQuickPickItem(t, checkmarks, true));
}
else {
items.push(new TagQuickPickItem(t, checkmarks, false));
}
}
}

+ 7
- 6
src/views/nodes/compareBranchNode.ts 查看文件

@ -60,11 +60,12 @@ export class CompareBranchNode extends ViewNode {
}
else {
label = `${this.branch.name}`;
description = `${GlyphChars.ArrowLeftRightLong}${
GlyphChars.Space
} ${GitService.shortenSha(this._compareWith, {
working: 'Working Tree'
})}`;
description = `${GlyphChars.ArrowLeftRightLong}${GlyphChars.Space} ${GitService.shortenSha(
this._compareWith,
{
working: 'Working Tree'
}
)}`;
state = TreeItemCollapsibleState.Collapsed;
}
@ -89,7 +90,7 @@ export class CompareBranchNode extends ViewNode {
async compareWith() {
const pick = await new ReferencesQuickPick(this.branch.repoPath).show(
`Compare ${this.branch.name} with${GlyphChars.Ellipsis}`,
{ allowEnteringRefs: true }
{ allowEnteringRefs: true, checked: this.branch.ref, checkmarks: true }
);
if (pick === undefined || pick instanceof CommandQuickPickItem) return;

+ 8
- 2
src/views/nodes/compareNode.ts 查看文件

@ -141,7 +141,12 @@ export class CompareNode extends ViewNode {
if (ref === undefined) {
const pick = await new ReferencesQuickPick(repoPath).show(
`Compare ${this.getRefName(this._selectedRef.ref)} with${GlyphChars.Ellipsis}`,
{ allowEnteringRefs: true }
{
allowEnteringRefs: true,
checked:
typeof this._selectedRef.ref === 'string' ? this._selectedRef.ref : this._selectedRef.ref.ref,
checkmarks: true
}
);
if (pick === undefined || pick instanceof CommandQuickPickItem) return;
@ -165,7 +170,8 @@ export class CompareNode extends ViewNode {
let autoCompare = false;
if (ref === undefined) {
const pick = await new ReferencesQuickPick(repoPath).show(`Compare${GlyphChars.Ellipsis}`, {
allowEnteringRefs: true
allowEnteringRefs: true,
checkmarks: false
});
if (pick === undefined || pick instanceof CommandQuickPickItem) return;

+ 2
- 1
src/views/nodes/fileHistoryTrackerNode.ts 查看文件

@ -72,7 +72,8 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
`Change the file history base to${GlyphChars.Ellipsis}`,
{
allowEnteringRefs: true,
checked: this._baseRef
checked: this._baseRef,
checkmarks: true
}
);
if (pick === undefined || pick instanceof CommandQuickPickItem) return;

+ 2
- 1
src/views/nodes/lineHistoryTrackerNode.ts 查看文件

@ -77,7 +77,8 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
`Change the line history base to${GlyphChars.Ellipsis}`,
{
allowEnteringRefs: true,
checked: this._base
checked: this._base,
checkmarks: true
}
);
if (pick === undefined || pick instanceof CommandQuickPickItem) return;

Loading…
取消
儲存