aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-18 04:28:42 +0000
committerBlaž Hrastnik2021-03-18 05:07:53 +0000
commit0f6624491bb35ccfa360e5fd48b3954d635c50ba (patch)
tree7ce89487ad4588e6f45006a6331ddc3b726909b6
parent8eaf9a432d14b6c2dd084dabbea606e4b1e3baa0 (diff)
Fix completion panicking if text changed before insert completed.
-rw-r--r--helix-term/src/commands.rs7
1 files changed, 4 insertions, 3 deletions
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);