diff --git a/src/extension.ts b/src/extension.ts index 264b203..36efdec 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -70,7 +70,7 @@ export async function activate(context: vscode.ExtensionContext): Promise const clipboardText = await vscode.env.clipboard.readText(); - if (contentChange.text !== clipboardText) { + if (!areEqualIgnoringWhitespace(contentChange.text, clipboardText)) { return; } @@ -150,3 +150,11 @@ function enabled(): boolean { function isEmptyOrWhitespace(s: string): boolean { return /^\s*$/.test(s); } + +function areEqualIgnoringWhitespace(a: string, b: string): boolean { + return removeWhitespace(a) === removeWhitespace(b); +} + +function removeWhitespace(s: string): string { + return s.replace(/\s*/g, ''); +}