mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-19 09:45:36 -05:00
Refactors commit quick pick commands
Splits showQuickCommitDetails into showQuickCommitDetails and showQuickCommitFileDetails Adds closeUnchangedFiles command Adds openChangedFiles command Adds diffDirectory command Adds contextual description to the `go back` commands Fixes #44 by adding a warning message about Git version requirements Fixes intermittent errors when adding active line annotations Fixes intermittent errors when opening multiple files via quick picks Updates dependencies Preps v2.11.0
This commit is contained in:
@@ -1,45 +1,20 @@
|
||||
'use strict';
|
||||
import { Iterables } from '../system';
|
||||
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
|
||||
import { Commands, Keyboard } from '../commands';
|
||||
import { GitCommit, GitLogCommit, GitProvider, GitUri } from '../gitProvider';
|
||||
import { GitLogCommit, GitProvider } from '../gitProvider';
|
||||
import { CommitWithFileStatusQuickPickItem } from './gitQuickPicks';
|
||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem } from './quickPicks';
|
||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFilesCommandQuickPickItem } from './quickPicks';
|
||||
import * as moment from 'moment';
|
||||
import * as path from 'path';
|
||||
|
||||
export { CommandQuickPickItem, CommitWithFileStatusQuickPickItem };
|
||||
|
||||
export class OpenCommitFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {
|
||||
|
||||
constructor(commit: GitCommit, item?: QuickPickItem) {
|
||||
const uri = GitProvider.toGitContentUri(commit);
|
||||
super(uri, item || {
|
||||
label: `$(file-symlink-file) Open File`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 as of \u00a0 $(git-commit) \u00a0 ${commit.sha} \u00a0\u2022\u00a0 ${commit.getFormattedPath()}`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class OpenCommitWorkingTreeFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {
|
||||
|
||||
constructor(commit: GitCommit, item?: QuickPickItem) {
|
||||
const uri = Uri.file(path.resolve(commit.repoPath, commit.fileName));
|
||||
super(uri, item || {
|
||||
label: `$(file-symlink-file) Open Working File`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 ${commit.getFormattedPath()}`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class OpenCommitFilesCommandQuickPickItem extends OpenFilesCommandQuickPickItem {
|
||||
|
||||
constructor(commit: GitLogCommit, item?: QuickPickItem) {
|
||||
const repoPath = commit.repoPath;
|
||||
const uris = commit.fileStatuses.map(_ => GitProvider.toGitContentUri(commit.sha, _.fileName, repoPath, commit.originalFileName));
|
||||
super(uris, item || {
|
||||
label: `$(file-symlink-file) Open Files`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 as of \u00a0 $(git-commit) \u00a0 ${commit.sha}`
|
||||
label: `$(file-symlink-file) Open Changed Files`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 in \u00a0$(git-commit) ${commit.sha}`
|
||||
//detail: `Opens all of the changed files in $(git-commit) ${commit.sha}`
|
||||
});
|
||||
}
|
||||
@@ -51,7 +26,7 @@ export class OpenCommitWorkingTreeFilesCommandQuickPickItem extends OpenFilesCom
|
||||
const repoPath = commit.repoPath;
|
||||
const uris = commit.fileStatuses.map(_ => Uri.file(path.resolve(repoPath, _.fileName)));
|
||||
super(uris, item || {
|
||||
label: `$(file-symlink-file) Open Working Files`,
|
||||
label: `$(file-symlink-file) Open Changed Working Files`,
|
||||
description: undefined
|
||||
//detail: `Opens all of the changed file in the working tree`
|
||||
});
|
||||
@@ -63,18 +38,35 @@ export class CommitDetailsQuickPick {
|
||||
static async show(commit: GitLogCommit, uri: Uri, goBackCommand?: CommandQuickPickItem): Promise<CommitWithFileStatusQuickPickItem | CommandQuickPickItem | undefined> {
|
||||
const items: (CommitWithFileStatusQuickPickItem | CommandQuickPickItem)[] = commit.fileStatuses.map(fs => new CommitWithFileStatusQuickPickItem(commit, fs.fileName, fs.status));
|
||||
|
||||
items.splice(0, 0, new CommandQuickPickItem({
|
||||
let index = 0;
|
||||
|
||||
items.splice(index++, 0, new CommandQuickPickItem({
|
||||
label: `$(clippy) Copy Commit Sha to Clipboard`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha}`
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 ${commit.sha}`
|
||||
}, Commands.CopyShaToClipboard, [uri, commit.sha]));
|
||||
|
||||
items.splice(1, 0, new CommandQuickPickItem({
|
||||
items.splice(index++, 0, new CommandQuickPickItem({
|
||||
label: `$(clippy) Copy Commit Message to Clipboard`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.message}`
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 ${commit.message}`
|
||||
}, Commands.CopyMessageToClipboard, [uri, commit.sha, commit.message]));
|
||||
|
||||
items.splice(2, 0, new OpenCommitWorkingTreeFilesCommandQuickPickItem(commit));
|
||||
items.splice(3, 0, new OpenCommitFilesCommandQuickPickItem(commit));
|
||||
items.splice(index++, 0, new CommandQuickPickItem({
|
||||
label: `$(git-compare) Directory Compare with Previous Commit`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.previousSha || `${commit.sha}^`} \u00a0 $(git-compare) \u00a0 $(git-commit) ${commit.sha}`
|
||||
}, Commands.DiffDirectory, [commit.uri, commit.previousSha || `${commit.sha}^`, commit.sha]));
|
||||
|
||||
items.splice(index++, 0, new CommandQuickPickItem({
|
||||
label: `$(git-compare) Directory Compare with Working Tree`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha} \u00a0 $(git-compare) \u00a0 $(file-directory) Working Tree`
|
||||
}, Commands.DiffDirectory, [uri, commit.sha]));
|
||||
|
||||
items.splice(index++, 0, new CommandQuickPickItem({
|
||||
label: `Changed Files`,
|
||||
description: null
|
||||
}, Commands.ShowQuickCommitDetails, [uri, commit.sha, commit, goBackCommand]));
|
||||
|
||||
items.push(new OpenCommitFilesCommandQuickPickItem(commit));
|
||||
items.push(new OpenCommitWorkingTreeFilesCommandQuickPickItem(commit));
|
||||
|
||||
if (goBackCommand) {
|
||||
items.splice(0, 0, goBackCommand);
|
||||
@@ -94,90 +86,6 @@ export class CommitDetailsQuickPick {
|
||||
|
||||
await Keyboard.instance.exitScope();
|
||||
|
||||
return pick;
|
||||
}
|
||||
}
|
||||
|
||||
export class CommitFileDetailsQuickPick {
|
||||
|
||||
static async show(git: GitProvider, commit: GitCommit, workingFileName: string, uri: Uri, currentCommand?: CommandQuickPickItem, goBackCommand?: CommandQuickPickItem, options: { showFileHistory?: boolean } = {}): Promise<CommandQuickPickItem | undefined> {
|
||||
const items: CommandQuickPickItem[] = [];
|
||||
|
||||
const workingName = (workingFileName && path.basename(workingFileName)) || path.basename(commit.fileName);
|
||||
|
||||
const isUncommitted = commit.isUncommitted;
|
||||
if (isUncommitted) {
|
||||
// Since we can't trust the previous sha on an uncommitted commit, find the last commit for this file
|
||||
const log = await git.getLogForFile(commit.uri.fsPath, undefined, undefined, undefined, 2);
|
||||
if (!log) return undefined;
|
||||
|
||||
commit = Iterables.first(log.commits.values());
|
||||
}
|
||||
|
||||
if (commit.previousSha) {
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(git-compare) Compare with Previous Commit`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.previousSha} \u00a0 $(git-compare) \u00a0 $(git-commit) ${commit.sha}`
|
||||
}, Commands.DiffWithPrevious, [commit.uri, commit]));
|
||||
}
|
||||
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(git-compare) Compare with Working Tree`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha} \u00a0 $(git-compare) \u00a0 $(file-text) ${workingName}`
|
||||
}, Commands.DiffWithWorking, [uri, commit]));
|
||||
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(diff) Show Changed Files`,
|
||||
description: undefined, //`\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha}`,
|
||||
detail: `Shows all of the changed files in commit $(git-commit) ${commit.sha}`
|
||||
}, Commands.ShowQuickCommitDetails, [new GitUri(commit.uri, commit), commit.sha, undefined, currentCommand]));
|
||||
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(clippy) Copy Commit Sha to Clipboard`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha}`
|
||||
}, Commands.CopyShaToClipboard, [uri, commit.sha]));
|
||||
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(clippy) Copy Commit Message to Clipboard`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.message}`
|
||||
}, Commands.CopyMessageToClipboard, [uri, commit.sha, commit.message]));
|
||||
|
||||
items.push(new OpenCommitWorkingTreeFileCommandQuickPickItem(commit));
|
||||
items.push(new OpenCommitFileCommandQuickPickItem(commit));
|
||||
|
||||
if (options.showFileHistory) {
|
||||
if (workingFileName) {
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(history) Show File History`,
|
||||
description: undefined, //`\u00a0 \u2014 \u00a0\u00a0 ${path.basename(commit.fileName)}`,
|
||||
detail: `Shows the commit history of the file, starting at the most recent commit`
|
||||
}, Commands.ShowQuickFileHistory, [commit.uri, undefined, undefined, currentCommand]));
|
||||
}
|
||||
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(history) Show Previous File History`,
|
||||
description: undefined, //`\u00a0 \u2014 \u00a0\u00a0 ${path.basename(commit.fileName)}`,
|
||||
detail: `Shows the previous commit history of the file, starting at $(git-commit) ${commit.sha}`
|
||||
}, Commands.ShowQuickFileHistory, [new GitUri(commit.uri, commit), undefined, undefined, currentCommand]));
|
||||
}
|
||||
|
||||
if (goBackCommand) {
|
||||
items.splice(0, 0, goBackCommand);
|
||||
}
|
||||
|
||||
await Keyboard.instance.enterScope(['left', goBackCommand]);
|
||||
|
||||
const pick = await window.showQuickPick(items, {
|
||||
matchOnDescription: true,
|
||||
placeHolder: `${commit.getFormattedPath()} \u2022 ${isUncommitted ? 'Uncommitted \u21E8 ' : '' }${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`,
|
||||
ignoreFocusOut: getQuickPickIgnoreFocusOut(),
|
||||
onDidSelectItem: (item: QuickPickItem) => {
|
||||
Keyboard.instance.setKeyCommand('right', item);
|
||||
}
|
||||
} as QuickPickOptions);
|
||||
|
||||
await Keyboard.instance.exitScope();
|
||||
|
||||
return pick;
|
||||
}
|
||||
}
|
||||
111
src/quickPicks/commitFileDetails.ts
Normal file
111
src/quickPicks/commitFileDetails.ts
Normal file
@@ -0,0 +1,111 @@
|
||||
'use strict';
|
||||
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 * as moment from 'moment';
|
||||
import * as path from 'path';
|
||||
|
||||
export class OpenCommitFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {
|
||||
|
||||
constructor(commit: GitCommit, item?: QuickPickItem) {
|
||||
const uri = GitProvider.toGitContentUri(commit);
|
||||
super(uri, item || {
|
||||
label: `$(file-symlink-file) Open File`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 ${path.basename(commit.fileName)} in \u00a0$(git-commit) ${commit.sha}`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export class OpenCommitWorkingTreeFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {
|
||||
|
||||
constructor(commit: GitCommit, item?: QuickPickItem) {
|
||||
const uri = Uri.file(path.resolve(commit.repoPath, commit.fileName));
|
||||
super(uri, item || {
|
||||
label: `$(file-symlink-file) Open Working File`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 ${path.basename(commit.fileName)}`
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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> {
|
||||
const items: CommandQuickPickItem[] = [];
|
||||
|
||||
const workingName = (workingFileName && path.basename(workingFileName)) || path.basename(commit.fileName);
|
||||
|
||||
const isUncommitted = commit.isUncommitted;
|
||||
if (isUncommitted) {
|
||||
// Since we can't trust the previous sha on an uncommitted commit, find the last commit for this file
|
||||
const log = await git.getLogForFile(commit.uri.fsPath, undefined, undefined, undefined, 2);
|
||||
if (!log) return undefined;
|
||||
|
||||
commit = Iterables.first(log.commits.values());
|
||||
}
|
||||
|
||||
if (!options.showFileHistory) {
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(git-commit) Show Commit Details`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha}`
|
||||
}, Commands.ShowQuickCommitDetails, [new GitUri(commit.uri, commit), commit.sha, commit, currentCommand]));
|
||||
}
|
||||
|
||||
if (commit.previousSha) {
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(git-compare) Compare with Previous Commit`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.previousSha} \u00a0 $(git-compare) \u00a0 $(git-commit) ${commit.sha}`
|
||||
}, Commands.DiffWithPrevious, [commit.uri, commit]));
|
||||
}
|
||||
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(git-compare) Compare with Working Tree`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 $(git-commit) ${commit.sha} \u00a0 $(git-compare) \u00a0 $(file-text) ${workingName}`
|
||||
}, Commands.DiffWithWorking, [uri, commit]));
|
||||
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(clippy) Copy Commit Sha to Clipboard`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 ${commit.sha}`
|
||||
}, Commands.CopyShaToClipboard, [uri, commit.sha]));
|
||||
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(clippy) Copy Commit Message to Clipboard`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 ${commit.message}`
|
||||
}, Commands.CopyMessageToClipboard, [uri, commit.sha, commit.message]));
|
||||
|
||||
items.push(new OpenCommitFileCommandQuickPickItem(commit));
|
||||
items.push(new OpenCommitWorkingTreeFileCommandQuickPickItem(commit));
|
||||
|
||||
if (workingFileName && options.showFileHistory) {
|
||||
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]));
|
||||
}
|
||||
|
||||
items.push(new CommandQuickPickItem({
|
||||
label: `$(history) Show ${workingFileName && options.showFileHistory ? 'Previous ' : ''}File History`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 of ${path.basename(commit.fileName)} \u00a0\u2022\u00a0 starting from \u00a0$(git-commit) ${commit.sha}`
|
||||
}, Commands.ShowQuickFileHistory, [new GitUri(commit.uri, commit), undefined, currentCommand]));
|
||||
|
||||
if (goBackCommand) {
|
||||
items.splice(0, 0, goBackCommand);
|
||||
}
|
||||
|
||||
await Keyboard.instance.enterScope(['left', goBackCommand]);
|
||||
|
||||
const pick = await window.showQuickPick(items, {
|
||||
matchOnDescription: true,
|
||||
placeHolder: `${commit.getFormattedPath()} \u2022 ${isUncommitted ? 'Uncommitted \u21E8 ' : '' }${commit.sha} \u2022 ${commit.author}, ${moment(commit.date).fromNow()} \u2022 ${commit.message}`,
|
||||
ignoreFocusOut: getQuickPickIgnoreFocusOut(),
|
||||
onDidSelectItem: (item: QuickPickItem) => {
|
||||
Keyboard.instance.setKeyCommand('right', item);
|
||||
}
|
||||
} as QuickPickOptions);
|
||||
|
||||
await Keyboard.instance.exitScope();
|
||||
|
||||
return pick;
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,11 @@ import { Commands, Keyboard } from '../commands';
|
||||
import { IGitLog } from '../gitProvider';
|
||||
import { CommitQuickPickItem } from './gitQuickPicks';
|
||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './quickPicks';
|
||||
|
||||
export { CommandQuickPickItem, CommitQuickPickItem };
|
||||
import * as path from 'path';
|
||||
|
||||
export class FileHistoryQuickPick {
|
||||
|
||||
static async show(log: IGitLog, uri: Uri, maxCount: number, defaultMaxCount: number, goBackCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
|
||||
static async show(log: IGitLog, uri: Uri, sha: string, maxCount: number, defaultMaxCount: number, goBackCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
|
||||
const items = Array.from(Iterables.map(log.commits.values(), c => new CommitQuickPickItem(c))) as (CommitQuickPickItem | CommandQuickPickItem)[];
|
||||
|
||||
if (maxCount !== 0 && items.length >= defaultMaxCount) {
|
||||
@@ -18,7 +17,7 @@ export class FileHistoryQuickPick {
|
||||
label: `$(sync) Show All Commits`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 Currently only showing the first ${defaultMaxCount} commits`,
|
||||
detail: `This may take a while`
|
||||
}, Commands.ShowQuickFileHistory, [uri, 0, undefined, goBackCommand]));
|
||||
}, Commands.ShowQuickFileHistory, [uri, 0, goBackCommand]));
|
||||
}
|
||||
|
||||
// Only show the full repo option if we are the root
|
||||
@@ -27,10 +26,15 @@ export class FileHistoryQuickPick {
|
||||
label: `$(repo) Show Repository History`,
|
||||
description: null,
|
||||
detail: 'Shows the commit history of the repository'
|
||||
}, Commands.ShowQuickRepoHistory, [undefined, undefined, undefined, new CommandQuickPickItem({
|
||||
label: `go back \u21A9`,
|
||||
description: null
|
||||
}, Commands.ShowQuickFileHistory, [uri, maxCount])]));
|
||||
}, Commands.ShowQuickRepoHistory,
|
||||
[
|
||||
undefined,
|
||||
undefined,
|
||||
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])
|
||||
]));
|
||||
}
|
||||
|
||||
if (goBackCommand) {
|
||||
@@ -44,7 +48,7 @@ export class FileHistoryQuickPick {
|
||||
const pick = await window.showQuickPick(items, {
|
||||
matchOnDescription: true,
|
||||
matchOnDetail: true,
|
||||
placeHolder: commit.getFormattedPath(),
|
||||
placeHolder: `${commit.getFormattedPath()}${sha ? ` \u00a0\u2022\u00a0 ${sha}` : ''}`,
|
||||
ignoreFocusOut: getQuickPickIgnoreFocusOut(),
|
||||
onDidSelectItem: (item: QuickPickItem) => {
|
||||
Keyboard.instance.setKeyCommand('right', item);
|
||||
|
||||
@@ -1,25 +1,12 @@
|
||||
'use strict';
|
||||
import { commands, QuickPickItem, TextEditor, Uri, window, workspace } from 'vscode';
|
||||
import { Commands } from '../commands';
|
||||
import { commands, QuickPickItem, TextEditor, Uri, workspace } from 'vscode';
|
||||
import { Commands, openEditor } from '../commands';
|
||||
import { IAdvancedConfig } from '../configuration';
|
||||
import { BuiltInCommands } from '../constants';
|
||||
|
||||
export function getQuickPickIgnoreFocusOut() {
|
||||
return !workspace.getConfiguration('gitlens').get<IAdvancedConfig>('advanced').quickPick.closeOnFocusOut;
|
||||
}
|
||||
|
||||
export async function openEditor(uri: Uri, pinned: boolean = false) {
|
||||
try {
|
||||
if (!pinned) return await commands.executeCommand(BuiltInCommands.Open, uri);
|
||||
|
||||
const document = await workspace.openTextDocument(uri);
|
||||
return window.showTextDocument(document, (window.activeTextEditor && window.activeTextEditor.viewColumn) || 1, true);
|
||||
}
|
||||
catch (ex) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export class CommandQuickPickItem implements QuickPickItem {
|
||||
|
||||
label: string;
|
||||
@@ -58,7 +45,7 @@ export class OpenFilesCommandQuickPickItem extends CommandQuickPickItem {
|
||||
|
||||
async execute(): Promise<{}> {
|
||||
for (const uri of this.uris) {
|
||||
openEditor(uri, true);
|
||||
await openEditor(uri, true);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import { IGitLog } from '../gitProvider';
|
||||
import { CommitQuickPickItem } from './gitQuickPicks';
|
||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './quickPicks';
|
||||
|
||||
export { CommandQuickPickItem, CommitQuickPickItem };
|
||||
|
||||
export class RepoHistoryQuickPick {
|
||||
|
||||
static async show(log: IGitLog, uri: Uri, maxCount: number, defaultMaxCount: number, goBackCommand?: CommandQuickPickItem): Promise<CommitQuickPickItem | CommandQuickPickItem | undefined> {
|
||||
@@ -18,7 +16,7 @@ export class RepoHistoryQuickPick {
|
||||
label: `$(sync) Show All Commits`,
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 Currently only showing the first ${defaultMaxCount} commits`,
|
||||
detail: `This may take a while`
|
||||
}, Commands.ShowQuickRepoHistory, [uri, 0, undefined, goBackCommand]));
|
||||
}, Commands.ShowQuickRepoHistory, [uri, 0, goBackCommand]));
|
||||
}
|
||||
|
||||
if (goBackCommand) {
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
'use strict';
|
||||
import { Iterables } from '../system';
|
||||
import { QuickPickItem, QuickPickOptions, Uri, window } from 'vscode';
|
||||
import { Keyboard } from '../commands';
|
||||
import { Commands, Keyboard } from '../commands';
|
||||
import { getGitStatusIcon, GitFileStatusItem } from '../gitProvider';
|
||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem, OpenFilesCommandQuickPickItem } from './quickPicks';
|
||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem } from './quickPicks';
|
||||
import * as path from 'path';
|
||||
|
||||
export { CommandQuickPickItem };
|
||||
|
||||
export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPickItem {
|
||||
|
||||
constructor(status: GitFileStatusItem, item?: QuickPickItem) {
|
||||
@@ -26,17 +24,17 @@ export class OpenStatusFileCommandQuickPickItem extends OpenFileCommandQuickPick
|
||||
}
|
||||
}
|
||||
|
||||
export class OpenStatusFilesCommandQuickPickItem extends OpenFilesCommandQuickPickItem {
|
||||
export class OpenStatusFilesCommandQuickPickItem extends CommandQuickPickItem {
|
||||
|
||||
constructor(statuses: GitFileStatusItem[], item?: QuickPickItem) {
|
||||
const repoPath = statuses.length && statuses[0].repoPath;
|
||||
const uris = statuses.map(_ => Uri.file(path.resolve(repoPath, _.fileName)));
|
||||
|
||||
super(uris, item || {
|
||||
label: `$(file-symlink-file) Open Files`,
|
||||
description: undefined,
|
||||
detail: `Opens all of the changed files in the repository`
|
||||
});
|
||||
super(item || {
|
||||
label: `$(file-symlink-file) Open Changed Files`,
|
||||
description: undefined
|
||||
//detail: `Opens all of the changed files in the repository`
|
||||
}, Commands.OpenChangedFiles, [undefined, uris]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,23 +47,42 @@ export class RepoStatusQuickPick {
|
||||
const items = Array.from(Iterables.map(statuses, s => new OpenStatusFileCommandQuickPickItem(s))) as (OpenStatusFileCommandQuickPickItem | OpenStatusFilesCommandQuickPickItem | CommandQuickPickItem)[];
|
||||
|
||||
if (statuses.some(_ => _.staged)) {
|
||||
const index = statuses.findIndex(_ => !_.staged);
|
||||
if (index > -1) {
|
||||
items.splice(index, 0, new OpenStatusFilesCommandQuickPickItem(statuses.filter(_ => _.status !== 'D' && !_.staged), {
|
||||
label: `$(file-symlink-file) Open Unstaged Files`,
|
||||
description: undefined,
|
||||
detail: `Opens all of the unstaged files in the repository`
|
||||
let index = 0;
|
||||
const unstagedIndex = statuses.findIndex(_ => !_.staged);
|
||||
if (unstagedIndex > -1) {
|
||||
items.splice(unstagedIndex, 0, new CommandQuickPickItem({
|
||||
label: `Unstaged Files`,
|
||||
description: undefined
|
||||
}, Commands.ShowQuickRepoStatus, [goBackCommand]));
|
||||
|
||||
items.splice(index++, 0, new OpenStatusFilesCommandQuickPickItem(statuses.filter(_ => _.status !== 'D' && _.staged), {
|
||||
label: `$(file-symlink-file) Open Staged Files`,
|
||||
description: undefined
|
||||
}));
|
||||
|
||||
items.splice(0, 0, new OpenStatusFilesCommandQuickPickItem(statuses.filter(_ => _.status !== 'D' && _.staged), {
|
||||
label: `$(file-symlink-file) Open Staged Files`,
|
||||
description: undefined,
|
||||
detail: `Opens all of the staged files in the repository`
|
||||
items.splice(index++, 0, new OpenStatusFilesCommandQuickPickItem(statuses.filter(_ => _.status !== 'D' && !_.staged), {
|
||||
label: `$(file-symlink-file) Open Unstaged Files`,
|
||||
description: undefined
|
||||
}));
|
||||
}
|
||||
|
||||
items.splice(index++, 0, new CommandQuickPickItem({
|
||||
label: `Staged Files`,
|
||||
description: undefined
|
||||
}, Commands.ShowQuickRepoStatus, [goBackCommand]));
|
||||
}
|
||||
else if (statuses.some(_ => !_.staged)) {
|
||||
items.splice(0, 0, new CommandQuickPickItem({
|
||||
label: `Unstaged Files`,
|
||||
description: undefined
|
||||
}, Commands.ShowQuickRepoStatus, [goBackCommand]));
|
||||
}
|
||||
|
||||
if (statuses.length) {
|
||||
items.splice(0, 0, new CommandQuickPickItem({
|
||||
label: '$(x) Close Unchanged Files',
|
||||
description: null
|
||||
}, Commands.CloseUnchangedFiles));
|
||||
items.splice(0, 0, new OpenStatusFilesCommandQuickPickItem(statuses.filter(_ => _.status !== 'D')));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user