Skip to content

Commit

Permalink
fix: lsp: Sort edits by start range, Omnisharp sends them in reverse
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Jun 2, 2022
1 parent 99e08f5 commit 3d91c99
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion helix-lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down

0 comments on commit 3d91c99

Please sign in to comment.