Skip to content

Commit

Permalink
Fixes gitkraken#1651 - search & compare opens file instead of diff
Browse files Browse the repository at this point in the history
  • Loading branch information
Svaught598 committed Aug 5, 2023
1 parent e0a0136 commit 928bf3e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

### Changed

- Changes _Search & Compare_ to default to open file instead of diff
- Closes [#1651](https://github.com/gitkraken/vscode-gitlens/issues/1651)

## [14.2.0] - 2023-08-04

### Added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ A big thanks to the people that have contributed to this project 🙏❤️:
- Zyck ([@qzyse2017](https://github.com/qzyse2017)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=qzyse2017)
- Yonatan Greenfeld ([@YonatanGreenfeld](https://github.com/YonatanGreenfeld)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=YonatanGreenfeld)
- WofWca ([@WofWca](https://github.com/WofWca)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=WofWca)
- Svaught598 ([@Svaught598](https://github.com/svaught598)) — [contributions](https://github.com/gitkraken/vscode-gitlens/commits?author=Svaught598)

Also special thanks to the people that have provided support, testing, brainstorming, etc:

Expand Down
26 changes: 7 additions & 19 deletions src/views/nodes/commitFileNode.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Command, Selection } from 'vscode';
import { MarkdownString, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
import type { DiffWithPreviousCommandArgs } from '../../commands';
import type { OpenFileAtRevisionCommandArgs } from '../../commands';
import { Commands, Schemes } from '../../constants';
import { StatusFileFormatter } from '../../git/formatters/statusFormatter';
import { GitUri } from '../../git/gitUri';
Expand Down Expand Up @@ -161,26 +161,14 @@ export class CommitFileNode<
}

override getCommand(): Command | undefined {
let line;
if (this.commit.lines.length) {
line = this.commit.lines[0].line - 1;
} else {
line = this._options.selection?.active.line ?? 0;
}

const commandArgs: DiffWithPreviousCommandArgs = {
commit: this.commit,
uri: GitUri.fromFile(this.file, this.commit.repoPath),
line: line,
showOptions: {
preserveFocus: true,
preview: true,
},
const commandArgs: OpenFileAtRevisionCommandArgs = {
revisionUri: GitUri.fromFile(this.file, this.uri.repoPath!, this.ref.ref),
};

return {
title: 'Open Changes with Previous Revision',
command: Commands.DiffWithPrevious,
arguments: [undefined, commandArgs],
title: 'Open File',
command: Commands.OpenFileAtRevision,
arguments: [commandArgs],
};
}
}

0 comments on commit 928bf3e

Please sign in to comment.