on master help sign in
fix: lsp: Sort edits by start range, Omnisharp sends them in reverse
commit3d91c99c3e64460d292e0393e89d723feefe10aa authorBlaž Hrastnik <blaz@mxxn.io> dateThu 2 Jun 2022, 11:30 (4 years ago) parent99e08f5
1 file changed+5−1
helix-lsp/src/lib.rs+5−1
helix-lsp/src/lib.rs+5−1
@@ -173,9 +173,13 @@ pub mod util {
173173
174174 pub fn generate_transaction_from_edits(
175175 doc: &Rope,
176− edits: Vec<lsp::TextEdit>,
176+ mut edits: Vec<lsp::TextEdit>,
177177 offset_encoding: OffsetEncoding,
178178 ) -> Transaction {
179+ // Sort edits by start range, since some LSPs (Omnisharp) send them
180+ // in reverse order.
181+ edits.sort_unstable_by_key(|edit| edit.range.start);
182+
179183 Transaction::change(
180184 doc,
181185 edits.into_iter().map(|edit| {