From c331721565a00850849e0a99fd325ae281bfb800 Mon Sep 17 00:00:00 2001 From: Blaž Hrastnik Date: Thu, 18 Mar 2021 15:07:02 +0900 Subject: Finish hiding doc.state / State as an implementation detail. --- helix-term/src/ui/mod.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'helix-term/src/ui') diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index f2376504..f7ba59cd 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -31,7 +31,7 @@ pub fn regex_prompt( prompt: String, fun: impl Fn(&mut Document, Regex) + 'static, ) -> Prompt { - let snapshot = cx.doc().state.clone(); + let snapshot = cx.doc().selection().clone(); Prompt::new( prompt, @@ -39,9 +39,10 @@ pub fn regex_prompt( move |editor: &mut Editor, input: &str, event: PromptEvent| { match event { PromptEvent::Abort => { - // revert state + // TODO: also revert doc + // TODO: also revert text let doc = &mut editor.view_mut().doc; - doc.state = snapshot.clone(); + doc.set_selection(snapshot.clone()); } PromptEvent::Validate => { // @@ -58,7 +59,8 @@ pub fn regex_prompt( let doc = &mut view.doc; // revert state to what it was before the last update - doc.state = snapshot.clone(); + // TODO: also revert text + doc.set_selection(snapshot.clone()); fun(doc, regex); -- cgit v1.2.3-70-g09d2