From 0f6624491bb35ccfa360e5fd48b3954d635c50ba Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Thu, 18 Mar 2021 13:28:42 +0900 Subject: Fix completion panicking if text changed before insert completed. --- helix-term/src/commands.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'helix-term/src') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 34e18e3e..1235a94e 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1290,7 +1290,7 @@ pub fn completion(cx: &mut Context) { // TODO: if no completion, show some message or something if !res.is_empty() { - let snapshot = doc.state.clone(); + // let snapshot = doc.state.clone(); let mut menu = ui::Menu::new( res, |item| { @@ -1304,13 +1304,13 @@ pub fn completion(cx: &mut Context) { PromptEvent::Abort => { // revert state let doc = &mut editor.view_mut().doc; - doc.state = snapshot.clone(); + // doc.state = snapshot.clone(); } PromptEvent::Validate => { let doc = &mut editor.view_mut().doc; // revert state to what it was before the last update - doc.state = snapshot.clone(); + // doc.state = snapshot.clone(); // extract as fn(doc, item): @@ -1350,6 +1350,7 @@ pub fn completion(cx: &mut Context) { } } + // TODO: <-- if state has changed by further input, transaction will panic on len let transaction = util::generate_transaction_from_edits(&doc.state, vec![edit]); doc.apply(&transaction); -- cgit v1.2.3-70-g09d2