Skip to content

Commit

Permalink
Corrupted diff when a file path includes unusual characters
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellourbani committed Feb 13, 2025
1 parent 47592b2 commit a5769a4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/normalize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { commands, TabInputTextDiff, TextEditor, Uri, window } from 'vscode';
import { CommandContext, setCommandContext } from './constants';
import { CommandContext } from './constants';
import { Container } from './container';

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

const normalizers: CodeNormalizer[] = [];

function setCommandContext(key: CommandContext | string, value: any) {
return commands.executeCommand('setContext', key, value);
}

const registerCodeNormalizer = (normalizer: CodeNormalizer) => {
if (normalizers.indexOf(normalizer) < 0) {
normalizers.push(normalizer);
Expand Down Expand Up @@ -43,7 +48,12 @@ export const toggleDiffNormalize = () => {
const tab = window.tabGroups.activeTabGroup.activeTab;
if (tab?.input instanceof TabInputTextDiff) {
const { original, modified } = tab.input;
return commands.executeCommand<void>('vscode.diff', toggleNorm(original), toggleNorm(modified), tab.label);
const controller = Container.bitbucketContext.prCommentController;
const origN = toggleNorm(original);
const modifN = toggleNorm(modified);
controller.provideComments(origN);
controller.provideComments(modifN);
return commands.executeCommand<void>('vscode.diff', origN, modifN, tab.label);
}
} catch (error) {}
return;
Expand Down

0 comments on commit a5769a4

Please sign in to comment.