Skip to content

Commit aa273e3

Browse files
fix: return empty response to textDocument/formatting if no changes
Do not send "edits" if the content remains unchanged after LSP formatting. Otherwise, Neovim reports an unsaved buffer even when no actual changes were made
1 parent 802e13c commit aa273e3

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44
<!-- Add all new changes here. They will be moved under a version at release -->
5+
* `FIX` prevent unnecessary edits by LSP formatting when content did not change
56

67
## 3.13.9
78
`2025-3-13`

script/core/formatting.lua

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ return function(uri, options)
2121
return
2222
end
2323

24+
if text == formattedText then
25+
return
26+
end
27+
2428
return {
2529
{
2630
start = state.ast.start,

0 commit comments

Comments
 (0)