diff options
author | Wojciech Kępka | 2021-06-11 07:30:27 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2021-06-11 09:34:46 +0000 |
commit | 0c2b99327a60d478ff6a4e4a2a15f69e61857569 (patch) | |
tree | 95b242cbc0dd8c30d7b10d85d9f3d37d613eafdd /helix-term | |
parent | a8a5bcd13d5c78b1613ad4ea47f8948a5ce4b8ce (diff) |
commands: Handle `t<ENTER>` as till newline
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands.rs | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index d8c56f4e..e5a30687 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -348,28 +348,34 @@ where // need to wait for next key cx.on_next_key(move |cx, event| { - if let KeyEvent { - code: KeyCode::Char(ch), - .. - } = event - { - let (view, doc) = cx.current(); - let text = doc.text().slice(..); + let ch = match event { + KeyEvent { + code: KeyCode::Enter, + .. + } => '\n', + KeyEvent { + code: KeyCode::Char(ch), + .. + } => ch, + _ => return, + }; - let selection = doc.selection(view.id).transform(|mut range| { - search_fn(text, ch, range.head, count, inclusive).map_or(range, |pos| { - if extend { - Range::new(range.anchor, pos) - } else { - // select - Range::new(range.head, pos) - } - // or (pos, pos) to move to found val - }) - }); + let (view, doc) = cx.current(); + let text = doc.text().slice(..); - doc.set_selection(view.id, selection); - } + let selection = doc.selection(view.id).transform(|mut range| { + search_fn(text, ch, range.head, count, inclusive).map_or(range, |pos| { + if extend { + Range::new(range.anchor, pos) + } else { + // select + Range::new(range.head, pos) + } + // or (pos, pos) to move to found val + }) + }); + + doc.set_selection(view.id, selection); }) } |