Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

comparing pasted content ignoring whitespace #47

Merged
merged 1 commit into from
Oct 14, 2024
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
10 changes: 9 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@

const clipboardText = await vscode.env.clipboard.readText();

if (contentChange.text !== clipboardText) {
if (!areEqualIgnoringWhitespace(contentChange.text, clipboardText)) {
return;
}

try {
const result: any = await lsClient.client.sendRequest('workspace/executeCommand', {

Check warning on line 78 in src/extension.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type

Check warning on line 78 in src/extension.ts

View workflow job for this annotation

GitHub Actions / test (stable, windows-latest)

Unexpected any. Specify a different type

Check warning on line 78 in src/extension.ts

View workflow job for this annotation

GitHub Actions / test (stable, ubuntu-latest)

Unexpected any. Specify a different type
command: 'azapi.convertJsonToAzapi',
arguments: [`jsonContent=${clipboardText}`],
});
Expand Down Expand Up @@ -150,3 +150,11 @@
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, '');
}
Loading