fix: lsp: Sort edits by start range, Omnisharp sends them in reverse

This commit is contained in:
Blaž Hrastnik 2022-06-02 11:30:22 +09:00
parent 99e08f50bd
commit 3d91c99c3e
No known key found for this signature in database
GPG key ID: 1238B9C4AD889640

View file

@ -173,9 +173,13 @@ pub fn lsp_range_to_range(
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| {