mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-20 01:35:36 -05:00
Adds commit navigation in quick pick lists via alt+, alt+.
Reworks keyboard context
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
|
||||
import { Commands, Keyboard } from '../commands';
|
||||
import { GitLogCommit, GitProvider } from '../gitProvider';
|
||||
import { GitLogCommit, GitProvider, IGitLog } from '../gitProvider';
|
||||
import { CommitWithFileStatusQuickPickItem } from './gitQuickPicks';
|
||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFilesCommandQuickPickItem } from './quickPicks';
|
||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, KeyNoopCommandQuickPickItem, OpenFilesCommandQuickPickItem } from './quickPicks';
|
||||
import * as moment from 'moment';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -35,7 +35,7 @@ export class OpenCommitWorkingTreeFilesCommandQuickPickItem extends OpenFilesCom
|
||||
|
||||
export class CommitDetailsQuickPick {
|
||||
|
||||
static async show(commit: GitLogCommit, uri: Uri, goBackCommand?: CommandQuickPickItem): Promise<CommitWithFileStatusQuickPickItem | CommandQuickPickItem | undefined> {
|
||||
static async show(git: GitProvider, commit: GitLogCommit, uri: Uri, goBackCommand?: CommandQuickPickItem, repoLog?: IGitLog): Promise<CommitWithFileStatusQuickPickItem | CommandQuickPickItem | undefined> {
|
||||
const items: (CommitWithFileStatusQuickPickItem | CommandQuickPickItem)[] = commit.fileStatuses.map(fs => new CommitWithFileStatusQuickPickItem(commit, fs.fileName, fs.status));
|
||||
|
||||
let index = 0;
|
||||
@@ -63,7 +63,7 @@ export class CommitDetailsQuickPick {
|
||||
items.splice(index++, 0, new CommandQuickPickItem({
|
||||
label: `Changed Files`,
|
||||
description: null
|
||||
}, Commands.ShowQuickCommitDetails, [uri, commit.sha, commit, goBackCommand]));
|
||||
}, Commands.ShowQuickCommitDetails, [uri, commit.sha, commit, goBackCommand, repoLog]));
|
||||
|
||||
items.push(new OpenCommitFilesCommandQuickPickItem(commit));
|
||||
items.push(new OpenCommitWorkingTreeFilesCommandQuickPickItem(commit));
|
||||
@@ -72,7 +72,30 @@ export class CommitDetailsQuickPick {
|
||||
items.splice(0, 0, goBackCommand);
|
||||
}
|
||||
|
||||
await Keyboard.instance.enterScope(['left', goBackCommand]);
|
||||
const previousCommand = commit.previousSha
|
||||
? new KeyCommandQuickPickItem(Commands.ShowQuickCommitDetails, [commit.previousUri, commit.previousSha, undefined, goBackCommand, repoLog])
|
||||
: new KeyNoopCommandQuickPickItem();
|
||||
|
||||
let nextCommand: CommandQuickPickItem | (() => Promise<CommandQuickPickItem>);
|
||||
if (repoLog) {
|
||||
nextCommand = commit.nextSha
|
||||
? new KeyCommandQuickPickItem(Commands.ShowQuickCommitDetails, [commit.nextUri, commit.nextSha, undefined, goBackCommand, repoLog])
|
||||
: new KeyNoopCommandQuickPickItem();
|
||||
}
|
||||
else {
|
||||
nextCommand = async () => {
|
||||
const log = await git.getLogForRepo(commit.repoPath, undefined, git.config.advanced.maxQuickHistory);
|
||||
const c = log && log.commits.get(commit.sha);
|
||||
if (!c) return new KeyNoopCommandQuickPickItem();
|
||||
return new KeyCommandQuickPickItem(Commands.ShowQuickCommitDetails, [c.nextUri, c.nextSha, undefined, goBackCommand, log]);
|
||||
};
|
||||
}
|
||||
|
||||
await Keyboard.instance.enterScope(
|
||||
['left', goBackCommand],
|
||||
[',', previousCommand],
|
||||
['.', nextCommand]
|
||||
);
|
||||
|
||||
const pick = await window.showQuickPick(items, {
|
||||
matchOnDescription: true,
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import { Iterables } from '../system';
|
||||
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
|
||||
import { Commands, Keyboard } from '../commands';
|
||||
import { GitCommit, GitLogCommit, GitProvider, GitUri } from '../gitProvider';
|
||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem } from './quickPicks';
|
||||
import { GitCommit, GitLogCommit, GitProvider, GitUri, IGitLog } from '../gitProvider';
|
||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, KeyCommandQuickPickItem, KeyNoopCommandQuickPickItem, OpenFileCommandQuickPickItem } from './quickPicks';
|
||||
import * as moment from 'moment';
|
||||
import * as path from 'path';
|
||||
|
||||
@@ -31,7 +31,7 @@ export class OpenCommitWorkingTreeFileCommandQuickPickItem extends OpenFileComma
|
||||
|
||||
export class CommitFileDetailsQuickPick {
|
||||
|
||||
static async show(git: GitProvider, commit: GitCommit | GitLogCommit, workingFileName: string, uri: Uri, goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem, options: { showFileHistory?: boolean } = {}): Promise<CommandQuickPickItem | undefined> {
|
||||
static async show(git: GitProvider, commit: GitLogCommit, workingFileName: string, uri: Uri, goBackCommand?: CommandQuickPickItem, currentCommand?: CommandQuickPickItem, options: { showFileHistory?: boolean } = {}, fileLog?: IGitLog): Promise<CommandQuickPickItem | undefined> {
|
||||
const items: CommandQuickPickItem[] = [];
|
||||
|
||||
const workingName = (workingFileName && path.basename(workingFileName)) || path.basename(commit.fileName);
|
||||
@@ -81,7 +81,7 @@ export class CommitFileDetailsQuickPick {
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(history) Show File History`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 of ${path.basename(commit.fileName)}`
|
||||
}, Commands.ShowQuickFileHistory, [commit.uri, undefined, currentCommand]));
|
||||
}, Commands.ShowQuickFileHistory, [commit.uri, undefined, currentCommand, fileLog]));
|
||||
}
|
||||
|
||||
items.push(new CommandQuickPickItem({
|
||||
@@ -93,7 +93,30 @@ export class CommitFileDetailsQuickPick {
|
||||
items.splice(0, 0, goBackCommand);
|
||||
}
|
||||
|
||||
await Keyboard.instance.enterScope(['left', goBackCommand]);
|
||||
const previousCommand = commit.previousSha
|
||||
? new KeyCommandQuickPickItem(Commands.ShowQuickCommitFileDetails, [commit.previousUri, commit.previousSha, undefined, goBackCommand, options, fileLog])
|
||||
: new KeyNoopCommandQuickPickItem();
|
||||
|
||||
let nextCommand: CommandQuickPickItem | (() => Promise<CommandQuickPickItem>);
|
||||
if (fileLog) {
|
||||
nextCommand = commit.nextSha
|
||||
? new KeyCommandQuickPickItem(Commands.ShowQuickCommitFileDetails, [commit.nextUri, commit.nextSha, undefined, goBackCommand, options, fileLog])
|
||||
: new KeyNoopCommandQuickPickItem();
|
||||
}
|
||||
else {
|
||||
nextCommand = async () => {
|
||||
const log = await git.getLogForFile(uri.fsPath, undefined, commit.repoPath, undefined, git.config.advanced.maxQuickHistory);
|
||||
const c = log && log.commits.get(commit.sha);
|
||||
if (!c) return new KeyNoopCommandQuickPickItem();
|
||||
return new KeyCommandQuickPickItem(Commands.ShowQuickCommitFileDetails, [c.nextUri, c.nextSha, undefined, goBackCommand, options, log]);
|
||||
};
|
||||
}
|
||||
|
||||
await Keyboard.instance.enterScope(
|
||||
['left', goBackCommand],
|
||||
[',', previousCommand],
|
||||
['.', nextCommand]
|
||||
);
|
||||
|
||||
const pick = await window.showQuickPick(items, {
|
||||
matchOnDescription: true,
|
||||
|
||||
@@ -33,7 +33,7 @@ export class FileHistoryQuickPick {
|
||||
new CommandQuickPickItem({
|
||||
label: `go back \u21A9`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 to history of \u00a0$(file-text) ${path.basename(uri.fsPath)}`
|
||||
}, Commands.ShowQuickFileHistory, [uri, maxCount])
|
||||
}, Commands.ShowQuickFileHistory, [uri, maxCount, undefined, log])
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,24 @@ export class CommandQuickPickItem implements QuickPickItem {
|
||||
}
|
||||
}
|
||||
|
||||
export class KeyCommandQuickPickItem extends CommandQuickPickItem {
|
||||
|
||||
constructor(protected command: Commands, protected args?: any[]) {
|
||||
super({ label: undefined, description: undefined }, command, args);
|
||||
}
|
||||
}
|
||||
|
||||
export class KeyNoopCommandQuickPickItem extends CommandQuickPickItem {
|
||||
|
||||
constructor() {
|
||||
super({ label: undefined, description: undefined }, undefined, undefined);
|
||||
}
|
||||
|
||||
execute(): Thenable<{}> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
export class OpenFileCommandQuickPickItem extends CommandQuickPickItem {
|
||||
|
||||
constructor(public uri: Uri, item: QuickPickItem) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './quickPicks';
|
||||
export class RepoHistoryQuickPick {
|
||||
|
||||
static async show(log: IGitLog, uri: Uri, maxCount: number, defaultMaxCount: number, goBackCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
|
||||
const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c, ` \u2014 ${c.fileName}`))) as (CommitQuickPickItem | CommandQuickPickItem)[];
|
||||
const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c, ` \u2014 ${c.fileNames}`))) as (CommitQuickPickItem | CommandQuickPickItem)[];
|
||||
|
||||
if (maxCount !== 0 && items.length >= defaultMaxCount) {
|
||||
items.splice(0, 0, new CommandQuickPickItem({
|
||||
|
||||
Reference in New Issue
Block a user