Browse Source

Adds show last quick pick command

main
Eric Amodio 7 years ago
parent
commit
a5d1d74d7b
10 changed files with 101 additions and 35 deletions
  1. +15
    -0
      package.json
  2. +24
    -23
      src/commands.ts
  3. +26
    -1
      src/commands/commands.ts
  4. +24
    -0
      src/commands/showLastQuickPick.ts
  5. +2
    -2
      src/commands/showQuickCommitDetails.ts
  6. +2
    -2
      src/commands/showQuickCommitFileDetails.ts
  7. +2
    -2
      src/commands/showQuickFileHistory.ts
  8. +2
    -2
      src/commands/showQuickRepoHistory.ts
  9. +2
    -2
      src/commands/showQuickRepoStatus.ts
  10. +2
    -1
      src/extension.ts

+ 15
- 0
package.json View File

@ -419,6 +419,11 @@
"category": "GitLens"
},
{
"command": "gitlens.showLastQuickPick",
"title": "Show Last Opened Quick Pick",
"category": "GitLens"
},
{
"command": "gitlens.showQuickCommitDetails",
"title": "Show Commit Details",
"category": "GitLens"
@ -515,6 +520,10 @@
"when": "gitlens:enabled"
},
{
"command": "gitlens.showLastQuickPick",
"when": "gitlens:enabled"
},
{
"command": "gitlens.showQuickCommitDetails",
"when": "gitlens:enabled && gitlens:isBlameable"
},
@ -695,6 +704,12 @@
"when": "editorTextFocus && gitlens:enabled && gitlens:canToggleCodeLens"
},
{
"command": "gitlens.showLastQuickPick",
"key": "alt+-",
"mac": "alt+-",
"when": "gitlens:enabled"
},
{
"command": "gitlens.showQuickFileHistory",
"key": "alt+h",
"mac": "alt+h",

+ 24
- 23
src/commands.ts View File

@ -2,30 +2,31 @@
import { commands } from 'vscode';
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 { CloseUnchangedFilesCommand } from './commands/closeUnchangedFiles';
export { CopyMessageToClipboardCommand } from './commands/copyMessageToClipboard';
export { CopyShaToClipboardCommand } from './commands/copyShaToClipboard';
export { DiffDirectoryCommand } from './commands/diffDirectory';
export { DiffLineWithPreviousCommand } from './commands/diffLineWithPrevious';
export { DiffLineWithWorkingCommand } from './commands/diffLineWithWorking';
export { DiffWithBranchCommand } from './commands/diffWithBranch';
export { DiffWithNextCommand } from './commands/diffWithNext';
export { DiffWithPreviousCommand } from './commands/diffWithPrevious';
export { DiffWithWorkingCommand } from './commands/diffWithWorking';
export { OpenChangedFilesCommand } from './commands/openChangedFiles';
export { ShowBlameCommand } from './commands/showBlame';
export { ShowBlameHistoryCommand } from './commands/showBlameHistory';
export { ShowFileHistoryCommand } from './commands/showFileHistory';
export { ShowQuickCommitDetailsCommand } from './commands/showQuickCommitDetails';
export { ShowQuickCommitFileDetailsCommand } from './commands/showQuickCommitFileDetails';
export { ShowQuickFileHistoryCommand } from './commands/showQuickFileHistory';
export { ShowQuickRepoHistoryCommand } from './commands/showQuickRepoHistory';
export { ShowQuickRepoStatusCommand } from './commands/showQuickRepoStatus';
export { ToggleBlameCommand } from './commands/toggleBlame';
export { ToggleCodeLensCommand } from './commands/toggleCodeLens';
export * from './commands/commands';
export * from './commands/closeUnchangedFiles';
export * from './commands/copyMessageToClipboard';
export * from './commands/copyShaToClipboard';
export * from './commands/diffDirectory';
export * from './commands/diffLineWithPrevious';
export * from './commands/diffLineWithWorking';
export * from './commands/diffWithBranch';
export * from './commands/diffWithNext';
export * from './commands/diffWithPrevious';
export * from './commands/diffWithWorking';
export * from './commands/openChangedFiles';
export * from './commands/showBlame';
export * from './commands/showBlameHistory';
export * from './commands/showFileHistory';
export * from './commands/showLastQuickPick';
export * from './commands/showQuickCommitDetails';
export * from './commands/showQuickCommitFileDetails';
export * from './commands/showQuickFileHistory';
export * from './commands/showQuickRepoHistory';
export * from './commands/showQuickRepoStatus';
export * from './commands/toggleBlame';
export * from './commands/toggleCodeLens';
export type CommandContext = 'gitlens:canToggleCodeLens' | 'gitlens:enabled' | 'gitlens:isBlameable' | 'gitlens:key';
export const CommandContext = {

+ 26
- 1
src/commands/commands.ts View File

@ -2,7 +2,7 @@
import { commands, Disposable, TextEditor, TextEditorEdit, Uri, window, workspace } from 'vscode';
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 = {
CloseUnchangedFiles: 'gitlens.closeUnchangedFiles' as Commands,
CopyMessageToClipboard: 'gitlens.copyMessageToClipboard' as Commands,
@ -18,6 +18,7 @@ export const Commands = {
ShowBlame: 'gitlens.showBlame' as Commands,
ShowBlameHistory: 'gitlens.showBlameHistory' as Commands,
ShowFileHistory: 'gitlens.showFileHistory' as Commands,
ShowLastQuickPick: 'gitlens.showLastQuickPick' as Commands,
ShowQuickCommitDetails: 'gitlens.showQuickCommitDetails' as Commands,
ShowQuickCommitFileDetails: 'gitlens.showQuickCommitFileDetails' as Commands,
ShowQuickFileHistory: 'gitlens.showQuickFileHistory' as Commands,
@ -44,6 +45,7 @@ export abstract class Command extends Disposable {
}
export abstract class EditorCommand extends Disposable {
private _disposable: Disposable;
constructor(command: Commands) {
@ -59,6 +61,7 @@ export abstract class EditorCommand extends Disposable {
}
export abstract class ActiveEditorCommand extends Disposable {
private _disposable: Disposable;
constructor(command: Commands) {
@ -77,6 +80,28 @@ export abstract class ActiveEditorCommand extends Disposable {
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) {
try {
if (!pinned) return await commands.executeCommand(BuiltInCommands.Open, uri);

+ 24
- 0
src/commands/showLastQuickPick.ts View 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`);
}
}
}

+ 2
- 2
src/commands/showQuickCommitDetails.ts View File

@ -1,12 +1,12 @@
'use strict';
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 { Logger } from '../logger';
import { CommandQuickPickItem, CommitDetailsQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks';
import * as path from 'path';
export class ShowQuickCommitDetailsCommand extends ActiveEditorCommand {
export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
constructor(private git: GitService, private repoPath: string) {
super(Commands.ShowQuickCommitDetails);

+ 2
- 2
src/commands/showQuickCommitFileDetails.ts View File

@ -1,12 +1,12 @@
'use strict';
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 { Logger } from '../logger';
import { CommandQuickPickItem, CommitFileDetailsQuickPick } from '../quickPicks';
import * as path from 'path';
export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCommand {
export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand {
constructor(private git: GitService) {
super(Commands.ShowQuickCommitFileDetails);

+ 2
- 2
src/commands/showQuickFileHistory.ts View File

@ -1,12 +1,12 @@
'use strict';
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 { Logger } from '../logger';
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
import * as path from 'path';
export class ShowQuickFileHistoryCommand extends ActiveEditorCommand {
export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
constructor(private git: GitService) {
super(Commands.ShowQuickFileHistory);

+ 2
- 2
src/commands/showQuickRepoHistory.ts View File

@ -1,11 +1,11 @@
'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from '../commands';
import { ActiveEditorCachedCommand, Commands } from '../commands';
import { GitService, GitUri, IGitLog } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, RepoHistoryQuickPick } from '../quickPicks';
export class ShowQuickRepoHistoryCommand extends ActiveEditorCommand {
export class ShowQuickRepoHistoryCommand extends ActiveEditorCachedCommand {
constructor(private git: GitService, private repoPath: string) {
super(Commands.ShowQuickRepoHistory);

+ 2
- 2
src/commands/showQuickRepoStatus.ts View File

@ -1,11 +1,11 @@
'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { ActiveEditorCachedCommand, Commands } from './commands';
import { GitService } from '../gitService';
import { Logger } from '../logger';
import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickPicks';
export class ShowQuickRepoStatusCommand extends ActiveEditorCommand {
export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand {
constructor(private git: GitService, private repoPath: string) {
super(Commands.ShowQuickRepoStatus);

+ 2
- 1
src/extension.ts View File

@ -10,7 +10,7 @@ import { CopyMessageToClipboardCommand, CopyShaToClipboardCommand } from './comm
import { DiffDirectoryCommand, DiffLineWithPreviousCommand, DiffLineWithWorkingCommand, DiffWithBranchCommand, DiffWithNextCommand, DiffWithPreviousCommand, DiffWithWorkingCommand} from './commands';
import { ShowBlameCommand, ToggleBlameCommand } 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 { Keyboard } from './commands';
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 ShowBlameHistoryCommand(git));
context.subscriptions.push(new ShowFileHistoryCommand(git));
context.subscriptions.push(new ShowLastQuickPickCommand());
context.subscriptions.push(new ShowQuickCommitDetailsCommand(git, repoPath));
context.subscriptions.push(new ShowQuickCommitFileDetailsCommand(git));
context.subscriptions.push(new ShowQuickFileHistoryCommand(git));

Loading…
Cancel
Save