From 3d91c99c3e64460d292e0393e89d723feefe10aa Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Thu, 2 Jun 2022 11:30:22 +0900 Subject: fix: lsp: Sort edits by start range, Omnisharp sends them in reverse --- helix-lsp/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'helix-lsp') 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, + mut edits: Vec, 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| { -- cgit v1.2.3-70-g09d2