Skip to content

Commit 75b9f3e

Browse files
authored
(fix) don't send text edit when format does not change code (#1143)
#1142
1 parent 6517f09 commit 75b9f3e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/language-server/src/plugins/svelte/SveltePlugin.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,17 @@ export class SveltePlugin
115115
parser: 'svelte' as any
116116
});
117117

118-
return [
119-
TextEdit.replace(
120-
Range.create(document.positionAt(0), document.positionAt(document.getTextLength())),
121-
formattedCode
122-
)
123-
];
118+
return document.getText() === formattedCode
119+
? []
120+
: [
121+
TextEdit.replace(
122+
Range.create(
123+
document.positionAt(0),
124+
document.positionAt(document.getTextLength())
125+
),
126+
formattedCode
127+
)
128+
];
124129

125130
function getSveltePlugin() {
126131
// Only provide our version of the svelte plugin if the user doesn't have one in

0 commit comments

Comments
 (0)