aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/ui/editor.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-04-01 01:39:46 +0000
committerBlaž Hrastnik2021-04-01 02:01:26 +0000
commit0dbd5b61ef4b75ba141b0b52636f3ba7c61c70cb (patch)
treed831ce257c3333d338ac41c235afac295bd90bf0 /helix-term/src/ui/editor.rs
parentceea5eacd814c5bbd8c6789610c87a882e3d72cf (diff)
Simplify code by providin cx.current() = (view, doc).
Diffstat (limited to 'helix-term/src/ui/editor.rs')
-rw-r--r--helix-term/src/ui/editor.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index d0822500..24c46bde 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -487,14 +487,12 @@ impl Component for EditorView {
EventResult::Consumed(None)
}
Event::Key(event) => {
- let view = cx.editor.view();
- let view_id = view.id;
- let id = view.doc;
- let mode = cx.editor.document(id).unwrap().mode();
+ let (view, doc) = cx.editor.current();
+ let mode = doc.mode();
let mut cxt = commands::Context {
+ view_id: view.id,
editor: &mut cx.editor,
- view_id,
count: 1,
callback: None,
callbacks: cx.callbacks,
@@ -524,9 +522,10 @@ impl Component for EditorView {
// appease borrowck
let callback = cxt.callback.take();
- cx.editor.ensure_cursor_in_view(cx.editor.tree.focus);
+ let (view, doc) = cx.editor.current();
+ view.ensure_cursor_in_view(doc);
- if mode == Mode::Normal && cx.editor.document(id).unwrap().mode() == Mode::Insert {
+ if mode == Mode::Normal && doc.mode() == Mode::Insert {
// HAXX: if we just entered insert mode from normal, clear key buf
// and record the command that got us into this mode.