Selaa lähdekoodia

Fixes diff with working/previous issues

main
Eric Amodio 4 vuotta sitten
vanhempi
commit
e3df97467a
9 muutettua tiedostoa jossa 48 lisäystä ja 39 poistoa
  1. +6
    -6
      package.json
  2. +2
    -1
      src/codelens/codeLensProvider.ts
  3. +8
    -3
      src/commands/diffWithPrevious.ts
  4. +8
    -4
      src/commands/diffWithWorking.ts
  5. +5
    -6
      src/commands/gitCommands.actions.ts
  6. +2
    -1
      src/views/nodes/commitFileNode.ts
  7. +2
    -1
      src/views/nodes/commitNode.ts
  8. +2
    -1
      src/views/nodes/statusFileNode.ts
  9. +13
    -16
      src/views/viewCommands.ts

+ 6
- 6
package.json Näytä tiedosto

@ -5180,18 +5180,18 @@
"alt": "gitlens.views.openFile"
},
{
"command": "gitlens.views.openChangesWithWorking",
"when": "viewItem =~ /gitlens:file\\b/",
"group": "inline@96"
},
{
"command": "gitlens.views.stageFile",
"when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+unstaged\\b)/",
"group": "inline@1"
"group": "inline@97"
},
{
"command": "gitlens.views.unstageFile",
"when": "!gitlens:readonly && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+staged\\b)/",
"group": "inline@1"
},
{
"command": "gitlens.views.openChangesWithWorking",
"when": "viewItem =~ /gitlens:file\\b/",
"group": "inline@97"
},
{

+ 2
- 1
src/codelens/codeLensProvider.ts Näytä tiedosto

@ -574,11 +574,12 @@ export class GitCodeLensProvider implements CodeLensProvider {
): T {
const commandArgs: DiffWithPreviousCommandArgs = {
commit: commit,
uri: lens.uri!.toFileUri(),
};
lens.command = {
title: title,
command: Commands.DiffWithPrevious,
arguments: [lens.uri!.toFileUri(), commandArgs],
arguments: [undefined, commandArgs],
};
return lens;
}

+ 8
- 3
src/commands/diffWithPrevious.ts Näytä tiedosto

@ -20,6 +20,7 @@ export interface DiffWithPreviousCommandArgs {
commit?: GitCommit;
inDiffRightEditor?: boolean;
uri?: Uri;
line?: number;
showOptions?: TextDocumentShowOptions;
}
@ -44,10 +45,14 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
}
async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithPreviousCommandArgs) {
uri = getCommandUri(uri, editor);
if (uri == null) return;
args = { ...args };
if (args.uri == null) {
uri = getCommandUri(uri, editor);
if (uri == null) return;
} else {
uri = args.uri;
}
if (args.line == null) {
args.line = editor?.selection.active.line ?? 0;
}

+ 8
- 4
src/commands/diffWithWorking.ts Näytä tiedosto

@ -10,6 +10,7 @@ import { Messages } from '../messages';
export interface DiffWithWorkingCommandArgs {
inDiffRightEditor?: boolean;
uri?: Uri;
line?: number;
showOptions?: TextDocumentShowOptions;
}
@ -34,12 +35,16 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
}
async execute(editor?: TextEditor, uri?: Uri, args?: DiffWithWorkingCommandArgs): Promise<any> {
uri = getCommandUri(uri, editor);
if (uri == null) return;
args = { ...args };
if (args.uri == null) {
uri = getCommandUri(uri, editor);
if (uri == null) return;
} else {
uri = args.uri;
}
let gitUri = await GitUri.fromUri(uri);
args = { ...args };
if (args.line == null) {
args.line = editor?.selection.active.line ?? 0;
}
@ -60,7 +65,6 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
}
}
// if (args.commit == null || args.commit.isUncommitted) {
// If the sha is missing, just let the user know the file matches
if (gitUri.sha == null) {
void window.showInformationMessage('File matches the working tree');

+ 5
- 6
src/commands/gitCommands.actions.ts Näytä tiedosto

@ -36,7 +36,7 @@ async function ensureRepo(repo: string | Repository): Promise {
export namespace GitActions {
export async function browseAtRevision(uri: Uri, options?: { openInNewWindow?: boolean }) {
void (await executeEditorCommand<BrowseRepoAtRevisionCommandArgs>(Commands.BrowseRepoAtRevision, uri, {
void (await executeEditorCommand<BrowseRepoAtRevisionCommandArgs>(Commands.BrowseRepoAtRevision, undefined, {
uri: uri,
openInNewWindow: options?.openInNewWindow,
}));
@ -977,11 +977,10 @@ export namespace GitActions {
options = { preserveFocus: true, preview: false, ...options };
void (await executeEditorCommand<DiffWithWorkingCommandArgs>(
Commands.DiffWithWorking,
GitUri.fromFile(file, ref.repoPath, ref.ref),
{ showOptions: options },
));
void (await executeEditorCommand<DiffWithWorkingCommandArgs>(Commands.DiffWithWorking, undefined, {
uri: GitUri.fromFile(file, ref.repoPath, ref.ref),
showOptions: options,
}));
}
export async function openDirectoryCompare(

+ 2
- 1
src/views/nodes/commitFileNode.ts Näytä tiedosto

@ -196,6 +196,7 @@ export class CommitFileNode extends ViewRefFileNode {
const commandArgs: DiffWithPreviousCommandArgs = {
commit: this.commit,
uri: GitUri.fromFile(this.file, this.commit.repoPath),
line: line,
showOptions: {
preserveFocus: true,
@ -205,7 +206,7 @@ export class CommitFileNode extends ViewRefFileNode {
return {
title: 'Open Changes with Previous Revision',
command: Commands.DiffWithPrevious,
arguments: [GitUri.fromFile(this.file, this.commit.repoPath), commandArgs],
arguments: [undefined, commandArgs],
};
}
}

+ 2
- 1
src/views/nodes/commitNode.ts Näytä tiedosto

@ -103,6 +103,7 @@ export class CommitNode extends ViewRefNode {
getCommand(): Command | undefined {
const commandArgs: DiffWithPreviousCommandArgs = {
commit: this.commit,
uri: this.uri,
line: 0,
showOptions: {
preserveFocus: true,
@ -112,7 +113,7 @@ export class CommitNode extends ViewRefNode {
return {
title: 'Open Changes with Previous Revision',
command: Commands.DiffWithPrevious,
arguments: [this.uri, commandArgs],
arguments: [undefined, commandArgs],
};
}
}

+ 2
- 1
src/views/nodes/statusFileNode.ts Näytä tiedosto

@ -229,6 +229,7 @@ export class StatusFileNode extends ViewNode {
if ((this._hasStagedChanges || this._hasUnstagedChanges) && this.commits.length === 1) {
const commandArgs: DiffWithPreviousCommandArgs = {
commit: this.commit,
uri: GitUri.fromFile(this.file, this.repoPath),
line: 0,
showOptions: {
preserveFocus: true,
@ -238,7 +239,7 @@ export class StatusFileNode extends ViewNode {
return {
title: 'Open Changes with Previous Revision',
command: Commands.DiffWithPrevious,
arguments: [GitUri.fromFile(this.file, this.repoPath), commandArgs],
arguments: [undefined, commandArgs],
};
}

+ 13
- 16
src/views/viewCommands.ts Näytä tiedosto

@ -639,9 +639,9 @@ export class ViewCommands {
break;
}
case Commands.DiffWithPrevious: {
const [uri, args] = command.arguments as [Uri, DiffWithPreviousCommandArgs];
const [, args] = command.arguments as [Uri, DiffWithPreviousCommandArgs];
args.showOptions!.preview = false;
void executeEditorCommand<DiffWithPreviousCommandArgs>(command.command, uri, args);
void executeEditorCommand<DiffWithPreviousCommandArgs>(command.command, undefined, args);
break;
}
default:
@ -725,13 +725,13 @@ export class ViewCommands {
if (!(node instanceof ViewRefFileNode) && !(node instanceof StatusFileNode)) return undefined;
if (node instanceof StatusFileNode) {
const args: DiffWithWorkingCommandArgs = {
return executeEditorCommand<DiffWithWorkingCommandArgs>(Commands.DiffWithWorking, undefined, {
uri: node.uri,
showOptions: {
preserveFocus: true,
preview: true,
},
};
return commands.executeCommand(Commands.DiffWithWorking, node.uri, args);
});
}
return GitActions.Commit.openChangesWithWorking(node.file, { repoPath: node.repoPath, ref: node.ref });
@ -748,14 +748,13 @@ export class ViewCommands {
return;
}
const args: OpenWorkingFileCommandArgs = {
void (await executeEditorCommand<OpenWorkingFileCommandArgs>(Commands.OpenWorkingFile, undefined, {
uri: node.uri,
showOptions: {
preserveFocus: true,
preview: false,
},
};
void (await commands.executeCommand(Commands.OpenWorkingFile, undefined, args));
}));
}
@debug()
@ -795,11 +794,10 @@ export class ViewCommands {
for (const file of files) {
const uri = GitUri.fromFile(file, repoPath, ref);
const args: OpenWorkingFileCommandArgs = {
await executeEditorCommand<OpenWorkingFileCommandArgs>(Commands.OpenWorkingFile, undefined, {
uri: uri,
showOptions: options,
};
await commands.executeCommand(Commands.OpenWorkingFile, undefined, args);
});
}
}
@ -886,13 +884,12 @@ export class ViewCommands {
private openRevisionOnRemote(node: CommitFileNode) {
if (!(node instanceof CommitFileNode) || node instanceof StashFileNode) return undefined;
const args: OpenFileOnRemoteCommandArgs = {
range: false,
};
return commands.executeCommand(
return executeEditorCommand<OpenFileOnRemoteCommandArgs>(
Commands.OpenFileInRemote,
node.commit.toGitUri(node.commit.status === 'D'),
args,
{
range: false,
},
);
}

Ladataan…
Peruuta
Tallenna