mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Adds show last quick pick command
This commit is contained in:
15
package.json
15
package.json
@@ -418,6 +418,11 @@
|
|||||||
"title": "Open File History Explorer",
|
"title": "Open File History Explorer",
|
||||||
"category": "GitLens"
|
"category": "GitLens"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.showLastQuickPick",
|
||||||
|
"title": "Show Last Opened Quick Pick",
|
||||||
|
"category": "GitLens"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.showQuickCommitDetails",
|
"command": "gitlens.showQuickCommitDetails",
|
||||||
"title": "Show Commit Details",
|
"title": "Show Commit Details",
|
||||||
@@ -514,6 +519,10 @@
|
|||||||
"command": "gitlens.showFileHistory",
|
"command": "gitlens.showFileHistory",
|
||||||
"when": "gitlens:enabled"
|
"when": "gitlens:enabled"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.showLastQuickPick",
|
||||||
|
"when": "gitlens:enabled"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.showQuickCommitDetails",
|
"command": "gitlens.showQuickCommitDetails",
|
||||||
"when": "gitlens:enabled && gitlens:isBlameable"
|
"when": "gitlens:enabled && gitlens:isBlameable"
|
||||||
@@ -694,6 +703,12 @@
|
|||||||
"mac": "alt+shift+b",
|
"mac": "alt+shift+b",
|
||||||
"when": "editorTextFocus && gitlens:enabled && gitlens:canToggleCodeLens"
|
"when": "editorTextFocus && gitlens:enabled && gitlens:canToggleCodeLens"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.showLastQuickPick",
|
||||||
|
"key": "alt+-",
|
||||||
|
"mac": "alt+-",
|
||||||
|
"when": "gitlens:enabled"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.showQuickFileHistory",
|
"command": "gitlens.showQuickFileHistory",
|
||||||
"key": "alt+h",
|
"key": "alt+h",
|
||||||
|
|||||||
@@ -2,30 +2,31 @@
|
|||||||
import { commands } from 'vscode';
|
import { commands } from 'vscode';
|
||||||
import { BuiltInCommands } from './constants';
|
import { BuiltInCommands } from './constants';
|
||||||
|
|
||||||
export { Keyboard, KeyboardScope, KeyMapping, KeyNoopCommand, Keys } from './commands/keyboard';
|
export * from './commands/keyboard';
|
||||||
|
|
||||||
export { ActiveEditorCommand, Command, Commands, EditorCommand, openEditor } from './commands/commands';
|
export * from './commands/commands';
|
||||||
export { CloseUnchangedFilesCommand } from './commands/closeUnchangedFiles';
|
export * from './commands/closeUnchangedFiles';
|
||||||
export { CopyMessageToClipboardCommand } from './commands/copyMessageToClipboard';
|
export * from './commands/copyMessageToClipboard';
|
||||||
export { CopyShaToClipboardCommand } from './commands/copyShaToClipboard';
|
export * from './commands/copyShaToClipboard';
|
||||||
export { DiffDirectoryCommand } from './commands/diffDirectory';
|
export * from './commands/diffDirectory';
|
||||||
export { DiffLineWithPreviousCommand } from './commands/diffLineWithPrevious';
|
export * from './commands/diffLineWithPrevious';
|
||||||
export { DiffLineWithWorkingCommand } from './commands/diffLineWithWorking';
|
export * from './commands/diffLineWithWorking';
|
||||||
export { DiffWithBranchCommand } from './commands/diffWithBranch';
|
export * from './commands/diffWithBranch';
|
||||||
export { DiffWithNextCommand } from './commands/diffWithNext';
|
export * from './commands/diffWithNext';
|
||||||
export { DiffWithPreviousCommand } from './commands/diffWithPrevious';
|
export * from './commands/diffWithPrevious';
|
||||||
export { DiffWithWorkingCommand } from './commands/diffWithWorking';
|
export * from './commands/diffWithWorking';
|
||||||
export { OpenChangedFilesCommand } from './commands/openChangedFiles';
|
export * from './commands/openChangedFiles';
|
||||||
export { ShowBlameCommand } from './commands/showBlame';
|
export * from './commands/showBlame';
|
||||||
export { ShowBlameHistoryCommand } from './commands/showBlameHistory';
|
export * from './commands/showBlameHistory';
|
||||||
export { ShowFileHistoryCommand } from './commands/showFileHistory';
|
export * from './commands/showFileHistory';
|
||||||
export { ShowQuickCommitDetailsCommand } from './commands/showQuickCommitDetails';
|
export * from './commands/showLastQuickPick';
|
||||||
export { ShowQuickCommitFileDetailsCommand } from './commands/showQuickCommitFileDetails';
|
export * from './commands/showQuickCommitDetails';
|
||||||
export { ShowQuickFileHistoryCommand } from './commands/showQuickFileHistory';
|
export * from './commands/showQuickCommitFileDetails';
|
||||||
export { ShowQuickRepoHistoryCommand } from './commands/showQuickRepoHistory';
|
export * from './commands/showQuickFileHistory';
|
||||||
export { ShowQuickRepoStatusCommand } from './commands/showQuickRepoStatus';
|
export * from './commands/showQuickRepoHistory';
|
||||||
export { ToggleBlameCommand } from './commands/toggleBlame';
|
export * from './commands/showQuickRepoStatus';
|
||||||
export { ToggleCodeLensCommand } from './commands/toggleCodeLens';
|
export * from './commands/toggleBlame';
|
||||||
|
export * from './commands/toggleCodeLens';
|
||||||
|
|
||||||
export type CommandContext = 'gitlens:canToggleCodeLens' | 'gitlens:enabled' | 'gitlens:isBlameable' | 'gitlens:key';
|
export type CommandContext = 'gitlens:canToggleCodeLens' | 'gitlens:enabled' | 'gitlens:isBlameable' | 'gitlens:key';
|
||||||
export const CommandContext = {
|
export const CommandContext = {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { commands, Disposable, TextEditor, TextEditorEdit, Uri, window, workspace } from 'vscode';
|
import { commands, Disposable, TextEditor, TextEditorEdit, Uri, window, workspace } from 'vscode';
|
||||||
import { BuiltInCommands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
|
|
||||||
export type Commands = 'gitlens.closeUnchangedFiles' | 'gitlens.copyMessageToClipboard' | 'gitlens.copyShaToClipboard' | 'gitlens.diffDirectory' | 'gitlens.diffWithBranch' | 'gitlens.diffWithNext' | 'gitlens.diffWithPrevious' | 'gitlens.diffLineWithPrevious' | 'gitlens.diffWithWorking' | 'gitlens.diffLineWithWorking' | 'gitlens.openChangedFiles' | 'gitlens.showBlame' | 'gitlens.showBlameHistory' | 'gitlens.showFileHistory' | 'gitlens.showQuickCommitDetails' | 'gitlens.showQuickCommitFileDetails' | 'gitlens.showQuickFileHistory' | 'gitlens.showQuickRepoHistory' | 'gitlens.showQuickRepoStatus' | 'gitlens.toggleBlame' | 'gitlens.toggleCodeLens';
|
export type Commands = 'gitlens.closeUnchangedFiles' | 'gitlens.copyMessageToClipboard' | 'gitlens.copyShaToClipboard' | 'gitlens.diffDirectory' | 'gitlens.diffWithBranch' | 'gitlens.diffWithNext' | 'gitlens.diffWithPrevious' | 'gitlens.diffLineWithPrevious' | 'gitlens.diffWithWorking' | 'gitlens.diffLineWithWorking' | 'gitlens.openChangedFiles' | 'gitlens.showBlame' | 'gitlens.showBlameHistory' | 'gitlens.showFileHistory' | 'gitlens.showLastQuickPick' | 'gitlens.showQuickCommitDetails' | 'gitlens.showQuickCommitFileDetails' | 'gitlens.showQuickFileHistory' | 'gitlens.showQuickRepoHistory' | 'gitlens.showQuickRepoStatus' | 'gitlens.toggleBlame' | 'gitlens.toggleCodeLens';
|
||||||
export const Commands = {
|
export const Commands = {
|
||||||
CloseUnchangedFiles: 'gitlens.closeUnchangedFiles' as Commands,
|
CloseUnchangedFiles: 'gitlens.closeUnchangedFiles' as Commands,
|
||||||
CopyMessageToClipboard: 'gitlens.copyMessageToClipboard' as Commands,
|
CopyMessageToClipboard: 'gitlens.copyMessageToClipboard' as Commands,
|
||||||
@@ -18,6 +18,7 @@ export const Commands = {
|
|||||||
ShowBlame: 'gitlens.showBlame' as Commands,
|
ShowBlame: 'gitlens.showBlame' as Commands,
|
||||||
ShowBlameHistory: 'gitlens.showBlameHistory' as Commands,
|
ShowBlameHistory: 'gitlens.showBlameHistory' as Commands,
|
||||||
ShowFileHistory: 'gitlens.showFileHistory' as Commands,
|
ShowFileHistory: 'gitlens.showFileHistory' as Commands,
|
||||||
|
ShowLastQuickPick: 'gitlens.showLastQuickPick' as Commands,
|
||||||
ShowQuickCommitDetails: 'gitlens.showQuickCommitDetails' as Commands,
|
ShowQuickCommitDetails: 'gitlens.showQuickCommitDetails' as Commands,
|
||||||
ShowQuickCommitFileDetails: 'gitlens.showQuickCommitFileDetails' as Commands,
|
ShowQuickCommitFileDetails: 'gitlens.showQuickCommitFileDetails' as Commands,
|
||||||
ShowQuickFileHistory: 'gitlens.showQuickFileHistory' as Commands,
|
ShowQuickFileHistory: 'gitlens.showQuickFileHistory' as Commands,
|
||||||
@@ -44,6 +45,7 @@ export abstract class Command extends Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export abstract class EditorCommand extends Disposable {
|
export abstract class EditorCommand extends Disposable {
|
||||||
|
|
||||||
private _disposable: Disposable;
|
private _disposable: Disposable;
|
||||||
|
|
||||||
constructor(command: Commands) {
|
constructor(command: Commands) {
|
||||||
@@ -59,6 +61,7 @@ export abstract class EditorCommand extends Disposable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export abstract class ActiveEditorCommand extends Disposable {
|
export abstract class ActiveEditorCommand extends Disposable {
|
||||||
|
|
||||||
private _disposable: Disposable;
|
private _disposable: Disposable;
|
||||||
|
|
||||||
constructor(command: Commands) {
|
constructor(command: Commands) {
|
||||||
@@ -77,6 +80,28 @@ export abstract class ActiveEditorCommand extends Disposable {
|
|||||||
abstract execute(editor: TextEditor, ...args: any[]): any;
|
abstract execute(editor: TextEditor, ...args: any[]): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let lastCommand: { command: string, args: any[] } = undefined;
|
||||||
|
export function getLastCommand() {
|
||||||
|
return lastCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class ActiveEditorCachedCommand extends ActiveEditorCommand {
|
||||||
|
|
||||||
|
constructor(private command: Commands) {
|
||||||
|
super(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
_execute(...args: any[]): any {
|
||||||
|
lastCommand = {
|
||||||
|
command: this.command,
|
||||||
|
args: args
|
||||||
|
};
|
||||||
|
return this.execute(window.activeTextEditor, ...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract execute(editor: TextEditor, ...args: any[]): any;
|
||||||
|
}
|
||||||
|
|
||||||
export async function openEditor(uri: Uri, pinned: boolean = false) {
|
export async function openEditor(uri: Uri, pinned: boolean = false) {
|
||||||
try {
|
try {
|
||||||
if (!pinned) return await commands.executeCommand(BuiltInCommands.Open, uri);
|
if (!pinned) return await commands.executeCommand(BuiltInCommands.Open, uri);
|
||||||
|
|||||||
24
src/commands/showLastQuickPick.ts
Normal file
24
src/commands/showLastQuickPick.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
'use strict';
|
||||||
|
import { commands, window } from 'vscode';
|
||||||
|
import { Command, Commands, getLastCommand } from './commands';
|
||||||
|
import { Logger } from '../logger';
|
||||||
|
|
||||||
|
export class ShowLastQuickPickCommand extends Command {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super(Commands.ShowLastQuickPick);
|
||||||
|
}
|
||||||
|
|
||||||
|
async execute() {
|
||||||
|
const command = getLastCommand();
|
||||||
|
if (!command) return undefined;
|
||||||
|
|
||||||
|
try {
|
||||||
|
return commands.executeCommand(command.command, ...command.args);
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
Logger.error('[GitLens.ShowLastQuickPickCommand]', ex);
|
||||||
|
return window.showErrorMessage(`Unable to show last quick pick. See output channel for more details`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, TextEditor, Uri, window } from 'vscode';
|
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands } from './commands';
|
import { ActiveEditorCachedCommand, Commands } from './commands';
|
||||||
import { GitCommit, GitLogCommit, GitService, GitUri, IGitLog } from '../gitService';
|
import { GitCommit, GitLogCommit, GitService, GitUri, IGitLog } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem, CommitDetailsQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks';
|
import { CommandQuickPickItem, CommitDetailsQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export class ShowQuickCommitDetailsCommand extends ActiveEditorCommand {
|
export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
||||||
|
|
||||||
constructor(private git: GitService, private repoPath: string) {
|
constructor(private git: GitService, private repoPath: string) {
|
||||||
super(Commands.ShowQuickCommitDetails);
|
super(Commands.ShowQuickCommitDetails);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { TextEditor, Uri, window } from 'vscode';
|
import { TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands } from './commands';
|
import { ActiveEditorCachedCommand, Commands } from './commands';
|
||||||
import { GitCommit, GitLogCommit, GitService, GitUri, IGitLog } from '../gitService';
|
import { GitCommit, GitLogCommit, GitService, GitUri, IGitLog } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem, CommitFileDetailsQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, CommitFileDetailsQuickPick } from '../quickPicks';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCommand {
|
export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand {
|
||||||
|
|
||||||
constructor(private git: GitService) {
|
constructor(private git: GitService) {
|
||||||
super(Commands.ShowQuickCommitFileDetails);
|
super(Commands.ShowQuickCommitFileDetails);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, Range, TextEditor, Uri, window } from 'vscode';
|
import { commands, Range, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands } from '../commands';
|
import { ActiveEditorCachedCommand, Commands } from '../commands';
|
||||||
import { GitService, GitUri, IGitLog } from '../gitService';
|
import { GitService, GitUri, IGitLog } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
|
export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
|
||||||
|
|
||||||
constructor(private git: GitService) {
|
constructor(private git: GitService) {
|
||||||
super(Commands.ShowQuickFileHistory);
|
super(Commands.ShowQuickFileHistory);
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, TextEditor, Uri, window } from 'vscode';
|
import { commands, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands } from '../commands';
|
import { ActiveEditorCachedCommand, Commands } from '../commands';
|
||||||
import { GitService, GitUri, IGitLog } from '../gitService';
|
import { GitService, GitUri, IGitLog } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem, RepoHistoryQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, RepoHistoryQuickPick } from '../quickPicks';
|
||||||
|
|
||||||
export class ShowQuickRepoHistoryCommand extends ActiveEditorCommand {
|
export class ShowQuickRepoHistoryCommand extends ActiveEditorCachedCommand {
|
||||||
|
|
||||||
constructor(private git: GitService, private repoPath: string) {
|
constructor(private git: GitService, private repoPath: string) {
|
||||||
super(Commands.ShowQuickRepoHistory);
|
super(Commands.ShowQuickRepoHistory);
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { TextEditor, Uri, window } from 'vscode';
|
import { TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands } from './commands';
|
import { ActiveEditorCachedCommand, Commands } from './commands';
|
||||||
import { GitService } from '../gitService';
|
import { GitService } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickPicks';
|
||||||
|
|
||||||
export class ShowQuickRepoStatusCommand extends ActiveEditorCommand {
|
export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand {
|
||||||
|
|
||||||
constructor(private git: GitService, private repoPath: string) {
|
constructor(private git: GitService, private repoPath: string) {
|
||||||
super(Commands.ShowQuickRepoStatus);
|
super(Commands.ShowQuickRepoStatus);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { CopyMessageToClipboardCommand, CopyShaToClipboardCommand } from './comm
|
|||||||
import { DiffDirectoryCommand, DiffLineWithPreviousCommand, DiffLineWithWorkingCommand, DiffWithBranchCommand, DiffWithNextCommand, DiffWithPreviousCommand, DiffWithWorkingCommand} from './commands';
|
import { DiffDirectoryCommand, DiffLineWithPreviousCommand, DiffLineWithWorkingCommand, DiffWithBranchCommand, DiffWithNextCommand, DiffWithPreviousCommand, DiffWithWorkingCommand} from './commands';
|
||||||
import { ShowBlameCommand, ToggleBlameCommand } from './commands';
|
import { ShowBlameCommand, ToggleBlameCommand } from './commands';
|
||||||
import { ShowBlameHistoryCommand, ShowFileHistoryCommand } from './commands';
|
import { ShowBlameHistoryCommand, ShowFileHistoryCommand } from './commands';
|
||||||
import { ShowQuickCommitDetailsCommand, ShowQuickCommitFileDetailsCommand, ShowQuickFileHistoryCommand, ShowQuickRepoHistoryCommand, ShowQuickRepoStatusCommand} from './commands';
|
import { ShowLastQuickPickCommand, ShowQuickCommitDetailsCommand, ShowQuickCommitFileDetailsCommand, ShowQuickFileHistoryCommand, ShowQuickRepoHistoryCommand, ShowQuickRepoStatusCommand} from './commands';
|
||||||
import { ToggleCodeLensCommand } from './commands';
|
import { ToggleCodeLensCommand } from './commands';
|
||||||
import { Keyboard } from './commands';
|
import { Keyboard } from './commands';
|
||||||
import { IAdvancedConfig, IBlameConfig } from './configuration';
|
import { IAdvancedConfig, IBlameConfig } from './configuration';
|
||||||
@@ -103,6 +103,7 @@ export async function activate(context: ExtensionContext) {
|
|||||||
context.subscriptions.push(new ToggleBlameCommand(annotationController));
|
context.subscriptions.push(new ToggleBlameCommand(annotationController));
|
||||||
context.subscriptions.push(new ShowBlameHistoryCommand(git));
|
context.subscriptions.push(new ShowBlameHistoryCommand(git));
|
||||||
context.subscriptions.push(new ShowFileHistoryCommand(git));
|
context.subscriptions.push(new ShowFileHistoryCommand(git));
|
||||||
|
context.subscriptions.push(new ShowLastQuickPickCommand());
|
||||||
context.subscriptions.push(new ShowQuickCommitDetailsCommand(git, repoPath));
|
context.subscriptions.push(new ShowQuickCommitDetailsCommand(git, repoPath));
|
||||||
context.subscriptions.push(new ShowQuickCommitFileDetailsCommand(git));
|
context.subscriptions.push(new ShowQuickCommitFileDetailsCommand(git));
|
||||||
context.subscriptions.push(new ShowQuickFileHistoryCommand(git));
|
context.subscriptions.push(new ShowQuickFileHistoryCommand(git));
|
||||||
|
|||||||
Reference in New Issue
Block a user