mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-17 01:35:37 -05:00
Adds compare with branch command
Adds branches quick pick
This commit is contained in:
42
src/quickPicks/branches.ts
Normal file
42
src/quickPicks/branches.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
import { QuickPickItem, QuickPickOptions, window } from 'vscode';
|
||||
import { GitBranch, GitUri } from '../gitService';
|
||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './quickPicks';
|
||||
import * as path from 'path';
|
||||
|
||||
export class BranchQuickPickItem implements QuickPickItem {
|
||||
|
||||
label: string;
|
||||
description: string;
|
||||
detail: string;
|
||||
|
||||
constructor(public branch: GitBranch) {
|
||||
this.label = `${branch.current ? '$(check)\u00a0' : '\u00a0\u00a0\u00a0\u00a0'} ${branch.name}`;
|
||||
this.description = branch.remote ? '\u00a0\u00a0 remote branch' : null;
|
||||
}
|
||||
}
|
||||
|
||||
export class BranchesQuickPick {
|
||||
|
||||
static async show(branches: GitBranch[], uri: GitUri, goBackCommand?: CommandQuickPickItem): Promise<BranchQuickPickItem | CommandQuickPickItem | undefined> {
|
||||
|
||||
const items = branches.map(_ => new BranchQuickPickItem(_)) as (BranchQuickPickItem | CommandQuickPickItem)[];
|
||||
|
||||
if (goBackCommand) {
|
||||
items.splice(0, 0, goBackCommand);
|
||||
}
|
||||
|
||||
// const scope = await Keyboard.instance.beginScope({ left: goBackCommand });
|
||||
|
||||
const pick = await window.showQuickPick(items,
|
||||
{
|
||||
placeHolder: `Compare ${path.basename(uri.fsPath)} to \u2026`,
|
||||
ignoreFocusOut: getQuickPickIgnoreFocusOut()
|
||||
} as QuickPickOptions);
|
||||
if (!pick) return undefined;
|
||||
|
||||
// await scope.dispose();
|
||||
|
||||
return pick;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user