diff --git a/src/commands/diffingCommands.ts b/src/commands/diffingCommands.ts index 62a36fa..8d1f953 100644 --- a/src/commands/diffingCommands.ts +++ b/src/commands/diffingCommands.ts @@ -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 !== ''); @@ -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, @@ -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) { diff --git a/src/commands/visitAtPointCommands.ts b/src/commands/visitAtPointCommands.ts index e3a9a37..8c3a57d 100644 --- a/src/commands/visitAtPointCommands.ts +++ b/src/commands/visitAtPointCommands.ts @@ -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))); } \ No newline at end of file