From c394017e0b86ea00b825347cbe28ebc248f78ac2 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Mon, 23 Aug 2021 15:58:51 +0200 Subject: [PATCH] (fix) don't send text edit when format does not change code #1142 --- .../src/plugins/svelte/SveltePlugin.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/language-server/src/plugins/svelte/SveltePlugin.ts b/packages/language-server/src/plugins/svelte/SveltePlugin.ts index c6fb168d1..34901f141 100644 --- a/packages/language-server/src/plugins/svelte/SveltePlugin.ts +++ b/packages/language-server/src/plugins/svelte/SveltePlugin.ts @@ -115,12 +115,17 @@ export class SveltePlugin parser: 'svelte' as any }); - return [ - TextEdit.replace( - Range.create(document.positionAt(0), document.positionAt(document.getTextLength())), - formattedCode - ) - ]; + return document.getText() === formattedCode + ? [] + : [ + TextEdit.replace( + Range.create( + document.positionAt(0), + document.positionAt(document.getTextLength()) + ), + formattedCode + ) + ]; function getSveltePlugin() { // Only provide our version of the svelte plugin if the user doesn't have one in