From acac68ff69ec742f8d8feba47b25e24d73119c5e Mon Sep 17 00:00:00 2001 From: Eduardo Farinati Date: Fri, 5 Apr 2024 23:17:22 -0300 Subject: [PATCH] Fix crash on lsp text edits with invalid ranges (#9649) --- helix-lsp/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/helix-lsp/src/lib.rs b/helix-lsp/src/lib.rs index 293863048cef..8b7a06cd741d 100644 --- a/helix-lsp/src/lib.rs +++ b/helix-lsp/src/lib.rs @@ -539,6 +539,16 @@ pub mod util { } else { return (0, 0, None); }; + + if start > end { + log::error!( + "Invalid LSP text edit start {:?} > end {:?}, discarding", + start, + end + ); + return (0, 0, None); + } + (start, end, replacement) }), )