Skip to content

Commit

Permalink
fix "visit change" uris for commit and stash detail views
Browse files Browse the repository at this point in the history
  • Loading branch information
kahole committed Dec 27, 2023
1 parent 6d41257 commit d438b66
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/commands/diffingCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async function showStash({ repository }: MenuState) {
}
}

export function stashToMagitChanges(nameStatusText: string, diff: string): MagitChange[] {
export function stashToMagitChanges(repository: MagitRepository, nameStatusText: string, diff: string): MagitChange[] {
const DIFF_PREFIX = 'diff --git';
const filesWithStatus = nameStatusText.split(Constants.LineSplitterRegex).filter(t => t !== '').map(s => s.split('\t'));
const diffs = diff.split(DIFF_PREFIX).filter(r => r !== '');
Expand All @@ -115,7 +115,7 @@ export function stashToMagitChanges(nameStatusText: string, diff: string): Magit

return diffs.map((diff, idx) => {
const [status, ...paths] = filesWithStatus[idx];
const uri = Uri.file(paths[paths.length - 1]);
const uri = Uri.from({ ...repository.gitRepository.rootUri, path: repository.gitRepository.rootUri.path + '/' + paths[paths.length - 1] });
const fileStatus = getStatusFromString(status);
return {
diff,
Expand Down Expand Up @@ -171,7 +171,7 @@ export async function showStashDetail(repository: MagitRepository, stash: Stash)
const nameStatusText = (await nameStatusTask).stdout;
const stashDiff = (await stashShowTask).stdout;

return ViewUtils.showView(uri, new StashDetailView(uri, stash, stashToMagitChanges(nameStatusText, stashDiff), stashUntrackedFiles));
return ViewUtils.showView(uri, new StashDetailView(uri, stash, stashToMagitChanges(repository, nameStatusText, stashDiff), stashUntrackedFiles));
}

async function showCommit({ repository }: MenuState) {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/visitAtPointCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ export async function visitCommit(repository: MagitRepository, commitHash: strin
const commit: MagitCommit = { hash: commitHash, message: '', parents: [] };

const uri = CommitDetailView.encodeLocation(repository, commit.hash);
return ViewUtils.showView(uri, new CommitDetailView(uri, commit, header.stdout, stashToMagitChanges(nameStatus.stdout, diffs.stdout)));
return ViewUtils.showView(uri, new CommitDetailView(uri, commit, header.stdout, stashToMagitChanges(repository, nameStatus.stdout, diffs.stdout)));
}

0 comments on commit d438b66

Please sign in to comment.