Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Clean up filename after parsing diff output #866

Merged
merged 2 commits into from
Mar 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/diffUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function isDiffToolAvailable(): boolean {
return diffToolAvailable;
}

export enum EditTypes { EDIT_DELETE, EDIT_INSERT, EDIT_REPLACE};
export enum EditTypes { EDIT_DELETE, EDIT_INSERT, EDIT_REPLACE };

export class Edit {
action: number;
Expand Down Expand Up @@ -128,7 +128,16 @@ function parseUniDiffs(diffOutput: jsDiff.IUniDiff[]): FilePatch[] {
edits.push(edit);
}
});
filePatches.push({fileName: uniDiff.oldFileName, edits: edits});

let fileName = uniDiff.oldFileName;
if (process.platform === 'win32') {
// Cleanup the file Name to fix https://github.com/Microsoft/vscode-go/issues/665
fileName = fileName.replace(/\\\\/g, '\\');
if (fileName.startsWith('"') && fileName.endsWith('"')) {
fileName = fileName.substr(1, fileName.length - 2);
}
}
filePatches.push({ fileName, edits });
});

return filePatches;
Expand Down