Переглянути джерело

Fixes broken open revision command

main
Eric Amodio 5 роки тому
джерело
коміт
8febb67c46
3 змінених файлів з 36 додано та 20 видалено
  1. +2
    -1
      CHANGELOG.md
  2. +9
    -1
      src/git/gitUri.ts
  3. +25
    -18
      src/views/viewCommands.ts

+ 2
- 1
CHANGELOG.md Переглянути файл

@ -17,7 +17,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Fixed
- Fixes issues with the _Line History_ view sometimes showing a duplicate and out of order commit
- Fixes the broken _Open File_ command on the root node of the _File History_ and _Line History_ views
- Fixes broken _Open File_ command on the root node of the _File History_ and _Line History_ views
- Fixes broken _Open Revision_ command on status files of the _Repositories_ view
## [9.6.0] - 2019-04-08

+ 9
- 1
src/git/gitUri.ts Переглянути файл

@ -333,7 +333,7 @@ export class GitUri extends ((Uri as any) as UriEx) {
const path = GitUri.resolve(fileName, repoPath);
return Uri.parse(
// Change encoded / back to / otherwise uri parsing won't work properly
`git:${encodeURIComponent(path).replace(/%2F/g, slash)}?${encodeURIComponent(
`${DocumentSchemes.Git}:${encodeURIComponent(path).replace(/%2F/g, slash)}?${encodeURIComponent(
JSON.stringify({
// Ensure we use the fsPath here, otherwise the url won't open properly
path: Uri.file(path).fsPath,
@ -396,6 +396,14 @@ export class GitUri extends ((Uri as any) as UriEx) {
shortSha = uriOrRef.shortSha;
}
if (ref === undefined || GitService.isUncommitted(ref)) {
if (GitService.isStagedUncommitted(ref)) {
return GitUri.git(fileName, repoPath);
}
return Uri.file(fileName);
}
const filePath = Strings.normalizePath(fileName, { addLeadingSlash: true });
const data: UriRevisionData = {
path: filePath,

+ 25
- 18
src/views/viewCommands.ts Переглянути файл

@ -22,7 +22,10 @@ import {
BranchTrackingStatusNode,
CommitFileNode,
CommitNode,
ContributorNode,
FileHistoryNode,
FolderNode,
LineHistoryNode,
RemoteNode,
RepositoryNode,
ResultsFileNode,
@ -34,10 +37,7 @@ import {
ViewRefNode,
viewSupportsNodeDismissal
} from './nodes';
import { ContributorNode } from './nodes/contributorNode';
import { Strings } from '../system/string';
import { FileHistoryNode } from './nodes/fileHistoryNode';
import { LineHistoryNode } from './nodes/lineHistoryNode';
export interface RefreshNodeCommandArgs {
maxCount?: number;
@ -392,10 +392,17 @@ export class ViewCommands implements Disposable {
}
private openFileRevision(
node: CommitFileNode | ResultsFileNode | StashFileNode,
node: CommitFileNode | ResultsFileNode | StashFileNode | StatusFileNode,
options: OpenFileRevisionCommandArgs = { showOptions: { preserveFocus: true, preview: false } }
) {
if (!(node instanceof CommitFileNode) && !(node instanceof ResultsFileNode)) return undefined;
if (
!(node instanceof CommitFileNode) &&
!(node instanceof StashFileNode) &&
!(node instanceof ResultsFileNode) &&
!(node instanceof StatusFileNode)
) {
return undefined;
}
let uri = options.uri;
if (uri == null) {
@ -417,6 +424,19 @@ export class ViewCommands implements Disposable {
return openEditor(uri, options.showOptions || { preserveFocus: true, preview: false });
}
private openFileRevisionInRemote(node: CommitFileNode) {
if (!(node instanceof CommitFileNode) || node instanceof StashFileNode) return undefined;
const args: OpenFileInRemoteCommandArgs = {
range: false
};
return commands.executeCommand(
Commands.OpenFileInRemote,
node.commit.toGitUri(node.commit.status === 'D'),
args
);
}
private async openChangedFileChanges(
node: CommitNode | StashNode,
options: TextDocumentShowOptions = { preserveFocus: false, preview: false }
@ -503,19 +523,6 @@ export class ViewCommands implements Disposable {
return commands.executeCommand(Commands.DiffWith, diffArgs);
}
private openFileRevisionInRemote(node: CommitFileNode | StashFileNode | StatusFileNode) {
if (!(node instanceof CommitFileNode) && !(node instanceof StatusFileNode)) return undefined;
const args: OpenFileInRemoteCommandArgs = {
range: false
};
return commands.executeCommand(
Commands.OpenFileInRemote,
node.commit.toGitUri(node.commit.status === 'D'),
args
);
}
private openInTerminal(node: RepositoryNode) {
if (!(node instanceof RepositoryNode)) return undefined;

Завантаження…
Відмінити
Зберегти