diff options
author | Blaž Hrastnik | 2022-06-02 02:30:22 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2022-06-02 05:07:19 +0000 |
commit | 3d91c99c3e64460d292e0393e89d723feefe10aa (patch) | |
tree | a77055cbec362f474c50ea55ce0921b31706f020 | |
parent | 99e08f50bdfeb24abe6afff8082ee160a7cadb6f (diff) |
fix: lsp: Sort edits by start range, Omnisharp sends them in reverse
-rw-r--r-- | helix-lsp/src/lib.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index f33646c8..2bc554e6 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -173,9 +173,13 @@ pub mod util { pub fn generate_transaction_from_edits( doc: &Rope, - edits: Vec<lsp::TextEdit>, + mut edits: Vec<lsp::TextEdit>, offset_encoding: OffsetEncoding, ) -> Transaction { + // Sort edits by start range, since some LSPs (Omnisharp) send them + // in reverse order. + edits.sort_unstable_by_key(|edit| edit.range.start); + Transaction::change( doc, edits.into_iter().map(|edit| { |