From d3bfa3e063b7862e691bff099c61a7fe5cb48181 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 c58d967b6..f1ffcdf88 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) }), )