diff options
author | Blaž Hrastnik | 2021-03-16 09:27:57 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-03-22 04:53:43 +0000 |
commit | bf95ee27aa3c9f137e34f30a01f25e4930a8b1bb (patch) | |
tree | 0867bdfc608540199f454c93e4a8d97a043036ef /helix-term/src/ui/mod.rs | |
parent | 5e6716c89c0909bc374e26bedbba703427f9aa26 (diff) |
Store Document on the Editor type, make View reference it.
Diffstat (limited to 'helix-term/src/ui/mod.rs')
-rw-r--r-- | helix-term/src/ui/mod.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs index ca133b66..cb1b36fa 100644 --- a/helix-term/src/ui/mod.rs +++ b/helix-term/src/ui/mod.rs @@ -39,9 +39,8 @@ pub fn regex_prompt( move |editor: &mut Editor, input: &str, event: PromptEvent| { match event { PromptEvent::Abort => { - // TODO: also revert doc // TODO: also revert text - let doc = &mut editor.view_mut().doc; + let doc = &mut editor.view().doc.borrow_mut(); doc.set_selection(snapshot.clone()); } PromptEvent::Validate => { @@ -56,13 +55,15 @@ pub fn regex_prompt( match Regex::new(input) { Ok(regex) => { let view = &mut editor.view_mut(); - let doc = &mut view.doc; + let mut doc = view.doc.borrow_mut(); // revert state to what it was before the last update // TODO: also revert text doc.set_selection(snapshot.clone()); - fun(doc, regex); + fun(&mut doc, regex); + + drop(doc); view.ensure_cursor_in_view(); } |