aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/editor.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-10-25 02:03:18 +0000
committerBlaž Hrastnik2021-10-25 02:09:09 +0000
commit3edca7854e66cbdb0c4baca25962a4f390fede55 (patch)
tree0cd0adda734fd3c02ec197b866ac2acaed2b1113 /helix-term/src/ui/editor.rs
parentbfb6cff5a9b0ff5c37085086f895d3f14eaa5782 (diff)
completion: fully revert state before apply & insertText common prefix
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r--helix-term/src/ui/editor.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 692696a6..850fec0f 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -13,7 +13,7 @@ use helix_core::{
syntax::{self, HighlightEvent},
unicode::segmentation::UnicodeSegmentation,
unicode::width::UnicodeWidthStr,
- LineEnding, Position, Range, Selection,
+ LineEnding, Position, Range, Selection, Transaction,
};
use helix_view::{
document::Mode,
@@ -721,7 +721,7 @@ impl EditorView {
pub fn set_completion(
&mut self,
- editor: &Editor,
+ editor: &mut Editor,
items: Vec<helix_lsp::lsp::CompletionItem>,
offset_encoding: helix_lsp::OffsetEncoding,
start_offset: usize,
@@ -736,6 +736,9 @@ impl EditorView {
return;
}
+ // Immediately initialize a savepoint
+ doc_mut!(editor).savepoint();
+
// TODO : propagate required size on resize to completion too
completion.required_size((size.width, size.height));
self.completion = Some(completion);
@@ -945,6 +948,9 @@ impl Component for EditorView {
if callback.is_some() {
// assume close_fn
self.completion = None;
+ // Clear any savepoints
+ let (_, doc) = current!(cxt.editor);
+ doc.savepoint = None;
cxt.editor.clear_idle_timer(); // don't retrigger
}
}
@@ -959,6 +965,9 @@ impl Component for EditorView {
completion.update(&mut cxt);
if completion.is_empty() {
self.completion = None;
+ // Clear any savepoints
+ let (_, doc) = current!(cxt.editor);
+ doc.savepoint = None;
cxt.editor.clear_idle_timer(); // don't retrigger
}
}