Przeglądaj źródła

Changes shortcut keys for diff with previous commands

Adds diff with next command
Fixes #45 - Keyboard Shortcut collision with Project Manager
Preps v2.11.2
main
Eric Amodio 7 lat temu
rodzic
commit
df838e883a
12 zmienionych plików z 126 dodań i 12 usunięć
  1. +9
    -0
      CHANGELOG.md
  2. +20
    -5
      package.json
  3. +3
    -2
      src/activeEditorTracker.ts
  4. +1
    -0
      src/commands.ts
  5. +2
    -1
      src/commands/commands.ts
  6. +1
    -0
      src/commands/diffLineWithPrevious.ts
  7. +74
    -0
      src/commands/diffWithNext.ts
  8. +1
    -0
      src/commands/diffWithPrevious.ts
  9. +3
    -1
      src/constants.ts
  10. +4
    -3
      src/extension.ts
  11. +2
    -0
      src/git/enrichers/logParserEnricher.ts
  12. +6
    -0
      src/git/gitEnrichment.ts

+ 9
- 0
CHANGELOG.md Wyświetl plik

@ -1,5 +1,14 @@
## Release Notes
### 2.11.2
- Adds `gitlens.diffWithNext` command to open a diff with the next commit
- Adds `alt+.` shortcut for the `gitlens.diffWithNext` command
- Changes `shift+alt+p` shortcut to `alt+,` for the `gitlens.diffWithPrevious` command
- Changes `alt+p` shortcut to `shift+alt+,` for the `gitlens.diffLineWithPrevious` command
- Removes `gitlens.toggleCodeLens` from Command Palette when not available
- Removes `gitlens.toggleCodeLens` shortcut key when not available
- Fixes (#45)[https://github.com/eamodio/vscode-gitlens/issues/45] - Keyboard Shortcut collision with Project Manager
### 2.11.1
- Adds blame and active line annotation support to git diff split view (right side)
- Adds command (compare, copy sha/message, etc) support to git diff split view (right side)

+ 20
- 5
package.json Wyświetl plik

@ -1,6 +1,6 @@
{
"name": "gitlens",
"version": "2.11.1",
"version": "2.11.2",
"author": {
"name": "Eric Amodio",
"email": "eamodio@gmail.com"
@ -357,6 +357,11 @@
"category": "GitLens"
},
{
"command": "gitlens.diffWithNext",
"title": "Compare with Next Commit",
"category": "GitLens"
},
{
"command": "gitlens.diffWithPrevious",
"title": "Compare with Previous Commit",
"category": "GitLens"
@ -466,6 +471,10 @@
"when": "gitlens:enabled"
},
{
"command": "gitlens.diffWithNext",
"when": "gitlens:enabled"
},
{
"command": "gitlens.diffWithPrevious",
"when": "gitlens:enabled"
},
@ -696,15 +705,21 @@
"when": "editorTextFocus && gitlens:enabled"
},
{
"command": "gitlens.diffWithNext",
"key": "alt+.",
"mac": "alt+.",
"when": "editorTextFocus && gitlens:enabled"
},
{
"command": "gitlens.diffLineWithPrevious",
"key": "alt+p",
"mac": "alt+p",
"key": "shift+alt+,",
"mac": "shift+alt+,",
"when": "editorTextFocus && gitlens:enabled"
},
{
"command": "gitlens.diffWithPrevious",
"key": "shift+alt+p",
"mac": "shift+alt+p",
"key": "alt+,",
"mac": "alt+,",
"when": "editorTextFocus && gitlens:enabled"
},
{

+ 3
- 2
src/activeEditorTracker.ts Wyświetl plik

@ -1,6 +1,7 @@
'use strict';
import { commands, Disposable, TextEditor, window } from 'vscode';
import { BuiltInCommands } from './constants';
export class ActiveEditorTracker extends Disposable {
@ -28,11 +29,11 @@ export class ActiveEditorTracker extends Disposable {
}
async close(): Promise<{}> {
return commands.executeCommand('workbench.action.closeActiveEditor');
return commands.executeCommand(BuiltInCommands.CloseActiveEditor);
}
async next(): Promise<{}> {
return commands.executeCommand('workbench.action.nextEditor');
return commands.executeCommand(BuiltInCommands.NextEditor);
}
async wait(timeout: number = 500): Promise<TextEditor> {

+ 1
- 0
src/commands.ts Wyświetl plik

@ -11,6 +11,7 @@ export { CopyShaToClipboardCommand } from './commands/copyShaToClipboard';
export { DiffDirectoryCommand } from './commands/diffDirectory';
export { DiffLineWithPreviousCommand } from './commands/diffLineWithPrevious';
export { DiffLineWithWorkingCommand } from './commands/diffLineWithWorking';
export { DiffWithNextCommand } from './commands/diffWithNext';
export { DiffWithPreviousCommand } from './commands/diffWithPrevious';
export { DiffWithWorkingCommand } from './commands/diffWithWorking';
export { OpenChangedFilesCommand } from './commands/openChangedFiles';

+ 2
- 1
src/commands/commands.ts Wyświetl plik

@ -2,12 +2,13 @@
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.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.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 const Commands = {
CloseUnchangedFiles: 'gitlens.closeUnchangedFiles' as Commands,
CopyMessageToClipboard: 'gitlens.copyMessageToClipboard' as Commands,
CopyShaToClipboard: 'gitlens.copyShaToClipboard' as Commands,
DiffDirectory: 'gitlens.diffDirectory' as Commands,
DiffWithNext: 'gitlens.diffWithNext' as Commands,
DiffWithPrevious: 'gitlens.diffWithPrevious' as Commands,
DiffLineWithPrevious: 'gitlens.diffLineWithPrevious' as Commands,
DiffWithWorking: 'gitlens.diffWithWorking' as Commands,

+ 1
- 0
src/commands/diffLineWithPrevious.ts Wyświetl plik

@ -60,6 +60,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
this.git.getVersionedFile(commit.uri.fsPath, commit.repoPath, commit.sha)
]);
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.uri.fsPath)} (${commit.sha}) ↔ ${path.basename(gitUri.fsPath)} (${gitUri.sha})`);
// TODO: Figure out how to focus the left pane
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
}
catch (ex) {

+ 74
- 0
src/commands/diffWithNext.ts Wyświetl plik

@ -0,0 +1,74 @@
'use strict';
import { Iterables } from '../system';
import { commands, Range, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, Commands } from './commands';
import { BuiltInCommands } from '../constants';
import { GitLogCommit, GitProvider, GitUri } from '../gitProvider';
import { Logger } from '../logger';
// import * as moment from 'moment';
import * as path from 'path';
export class DiffWithNextCommand extends ActiveEditorCommand {
constructor(private git: GitProvider) {
super(Commands.DiffWithNext);
}
async execute(editor: TextEditor): Promise<any>;
async execute(editor: TextEditor, uri: Uri): Promise<any>;
async execute(editor: TextEditor, uri: Uri, commit: GitLogCommit, range?: Range): Promise<any>;
async execute(editor: TextEditor, uri: Uri, commit: GitLogCommit, line?: number): Promise<any>;
async execute(editor: TextEditor, uri?: Uri, commit?: GitLogCommit, rangeOrLine?: Range | number): Promise<any> {
if (!(uri instanceof Uri)) {
if (!editor || !editor.document) return undefined;
uri = editor.document.uri;
}
let line = (editor && editor.selection.active.line) || 0;
if (typeof rangeOrLine === 'number') {
line = rangeOrLine || line;
rangeOrLine = undefined;
}
if (!commit || !(commit instanceof GitLogCommit) || rangeOrLine instanceof Range) {
const gitUri = await GitUri.fromUri(uri, this.git);
try {
if (!gitUri.sha) {
// If the file is uncommitted, treat it as a DiffWithWorking
if (await this.git.isFileUncommitted(gitUri.fsPath, gitUri.repoPath)) {
return commands.executeCommand(Commands.DiffWithWorking, uri);
}
}
const sha = (commit && commit.sha) || gitUri.sha;
const log = await this.git.getLogForFile(gitUri.fsPath, undefined, gitUri.repoPath, rangeOrLine as Range, sha ? undefined : 2);
if (!log) return window.showWarningMessage(`Unable to open diff. File is probably not under source control`);
commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
}
catch (ex) {
Logger.error('[GitLens.DiffWithNextCommand]', `getLogForFile(${gitUri.fsPath})`, ex);
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
}
}
if (!commit.nextSha) {
return commands.executeCommand(Commands.DiffWithWorking, uri);
}
try {
const [rhs, lhs] = await Promise.all([
this.git.getVersionedFile(commit.nextUri.fsPath, commit.repoPath, commit.nextSha),
this.git.getVersionedFile(commit.uri.fsPath, commit.repoPath, commit.sha)
]);
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.uri.fsPath)} (${commit.sha}) ↔ ${path.basename(commit.nextUri.fsPath)} (${commit.nextSha})`);
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
}
catch (ex) {
Logger.error('[GitLens.DiffWithNextCommand]', 'getVersionedFile', ex);
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
}
}
}

+ 1
- 0
src/commands/diffWithPrevious.ts Wyświetl plik

@ -64,6 +64,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
this.git.getVersionedFile(commit.previousUri.fsPath, commit.repoPath, commit.previousSha)
]);
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.previousUri.fsPath)} (${commit.previousSha}) ↔ ${path.basename(commit.uri.fsPath)} (${commit.sha})`);
// TODO: Figure out how to focus the left pane
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
}
catch (ex) {

+ 3
- 1
src/constants.ts Wyświetl plik

@ -2,14 +2,16 @@
export const RepoPath = 'repoPath';
export type BuiltInCommands = 'cursorMove' | 'editor.action.showReferences' | 'editor.action.toggleRenderWhitespace' | 'editorScroll' | 'revealLine' | 'setContext' | 'vscode.diff' | 'vscode.executeDocumentSymbolProvider' | 'vscode.executeCodeLensProvider' | 'vscode.open';
export type BuiltInCommands = 'cursorMove' | 'editor.action.showReferences' | 'editor.action.toggleRenderWhitespace' | 'editorScroll' | 'revealLine' | 'setContext' | 'vscode.diff' | 'vscode.executeDocumentSymbolProvider' | 'vscode.executeCodeLensProvider' | 'vscode.open' | 'workbench.action.closeActiveEditor' | 'workbench.action.nextEditor';
export const BuiltInCommands = {
CloseActiveEditor: 'workbench.action.closeActiveEditor' as BuiltInCommands,
CursorMove: 'cursorMove' as BuiltInCommands,
Diff: 'vscode.diff' as BuiltInCommands,
EditorScroll: 'editorScroll' as BuiltInCommands,
ExecuteDocumentSymbolProvider: 'vscode.executeDocumentSymbolProvider' as BuiltInCommands,
ExecuteCodeLensProvider: 'vscode.executeCodeLensProvider' as BuiltInCommands,
Open: 'vscode.open' as BuiltInCommands,
NextEditor: 'workbench.action.nextEditor' as BuiltInCommands,
RevealLine: 'revealLine' as BuiltInCommands,
SetContext: 'setContext' as BuiltInCommands,
ShowReferences: 'editor.action.showReferences' as BuiltInCommands,

+ 4
- 3
src/extension.ts Wyświetl plik

@ -7,7 +7,7 @@ import { configureCssCharacters } from './blameAnnotationFormatter';
import { CommandContext, setCommandContext } from './commands';
import { CloseUnchangedFilesCommand, OpenChangedFilesCommand } from './commands';
import { CopyMessageToClipboardCommand, CopyShaToClipboardCommand } from './commands';
import { DiffDirectoryCommand, DiffLineWithPreviousCommand, DiffLineWithWorkingCommand, DiffWithPreviousCommand, DiffWithWorkingCommand} from './commands';
import { DiffDirectoryCommand, DiffLineWithPreviousCommand, DiffLineWithWorkingCommand, DiffWithNextCommand, DiffWithPreviousCommand, DiffWithWorkingCommand} from './commands';
import { ShowBlameCommand, ToggleBlameCommand } from './commands';
import { ShowBlameHistoryCommand, ShowFileHistoryCommand } from './commands';
import { ShowQuickCommitDetailsCommand, ShowQuickCommitFileDetailsCommand, ShowQuickFileHistoryCommand, ShowQuickRepoHistoryCommand, ShowQuickRepoStatusCommand} from './commands';
@ -93,10 +93,11 @@ export async function activate(context: ExtensionContext) {
context.subscriptions.push(new CopyMessageToClipboardCommand(git, repoPath));
context.subscriptions.push(new CopyShaToClipboardCommand(git, repoPath));
context.subscriptions.push(new DiffDirectoryCommand(git, repoPath));
context.subscriptions.push(new DiffWithWorkingCommand(git));
context.subscriptions.push(new DiffLineWithPreviousCommand(git));
context.subscriptions.push(new DiffLineWithWorkingCommand(git));
context.subscriptions.push(new DiffWithNextCommand(git));
context.subscriptions.push(new DiffWithPreviousCommand(git));
context.subscriptions.push(new DiffLineWithPreviousCommand(git));
context.subscriptions.push(new DiffWithWorkingCommand(git));
context.subscriptions.push(new ShowBlameCommand(annotationController));
context.subscriptions.push(new ToggleBlameCommand(annotationController));
context.subscriptions.push(new ShowBlameHistoryCommand(git));

+ 2
- 0
src/git/enrichers/logParserEnricher.ts Wyświetl plik

@ -200,9 +200,11 @@ export class GitLogParserEnricher implements IGitEnricher {
if (recentCommit) {
recentCommit.previousSha = commit.sha;
commit.nextSha = recentCommit.sha;
// Only add a filename if this is a file log
if (type === 'file') {
recentCommit.previousFileName = commit.originalFileName || commit.fileName;
commit.nextFileName = recentCommit.originalFileName || recentCommit.fileName;
}
}
recentCommit = commit;

+ 6
- 0
src/git/gitEnrichment.ts Wyświetl plik

@ -108,6 +108,8 @@ export type GitLogType = 'file' | 'repo';
export class GitLogCommit extends GitCommit {
fileStatuses: { status: GitFileStatus, fileName: string }[];
nextSha?: string;
nextFileName?: string;
status: GitFileStatus;
constructor(
@ -135,6 +137,10 @@ export class GitLogCommit extends GitCommit {
this.fileStatuses = [{ status: status, fileName: fileName }];
}
}
get nextUri(): Uri {
return this.nextFileName ? Uri.file(path.join(this.repoPath, this.nextFileName)) : this.uri;
}
}
export interface IGitCommitLine {

Ładowanie…
Anuluj
Zapisz