-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix an off-by-one error in the LSP formatter (#1605)
* Fix an off-by-one error in the LSP formatter According to [the LSP specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#range) the end of a text range in the protocol is exclusive. When executing a formatting request in the language server we want to replace the entire document with the formatted result, including any trailing newlines. This means we need to specify the beginning of the line after the very last line in the document as the end of the range of text to be replaced. This also fixes an annoying behaviour when formatting with NLS in Helix. Previously, Helix would insist on selecting (what looked like) the entire document on every formatting request. With this change, Helix refrains from doing this. * Update LSP snapshot test
- Loading branch information
Showing
3 changed files
with
11 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
source: lsp/nls/tests/main.rs | ||
expression: output | ||
--- | ||
[<0:0-1:8> { | ||
[<0:0-2:0> { | ||
foo = "bar", | ||
baz = 7 | ||
} | ||
|