Skip to content

Commit a5769a4

Browse files
Corrupted diff when a file path includes unusual characters
Fixes atlassian#111
1 parent 47592b2 commit a5769a4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/normalize.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { commands, TabInputTextDiff, TextEditor, Uri, window } from 'vscode';
2-
import { CommandContext, setCommandContext } from './constants';
2+
import { CommandContext } from './constants';
3+
import { Container } from './container';
34

45
interface CodeNormalizer {
56
isRelevant: (u: Uri) => boolean;
@@ -8,6 +9,10 @@ interface CodeNormalizer {
89

910
const normalizers: CodeNormalizer[] = [];
1011

12+
function setCommandContext(key: CommandContext | string, value: any) {
13+
return commands.executeCommand('setContext', key, value);
14+
}
15+
1116
const registerCodeNormalizer = (normalizer: CodeNormalizer) => {
1217
if (normalizers.indexOf(normalizer) < 0) {
1318
normalizers.push(normalizer);
@@ -43,7 +48,12 @@ export const toggleDiffNormalize = () => {
4348
const tab = window.tabGroups.activeTabGroup.activeTab;
4449
if (tab?.input instanceof TabInputTextDiff) {
4550
const { original, modified } = tab.input;
46-
return commands.executeCommand<void>('vscode.diff', toggleNorm(original), toggleNorm(modified), tab.label);
51+
const controller = Container.bitbucketContext.prCommentController;
52+
const origN = toggleNorm(original);
53+
const modifN = toggleNorm(modified);
54+
controller.provideComments(origN);
55+
controller.provideComments(modifN);
56+
return commands.executeCommand<void>('vscode.diff', origN, modifN, tab.label);
4757
}
4858
} catch (error) {}
4959
return;

0 commit comments

Comments
 (0)