mirror of
https://github.com/ilyakooo0/helix.git
synced 2024-11-29 05:27:07 +03:00
commands: Handle t<ENTER>
as till newline
This commit is contained in:
parent
a8a5bcd13d
commit
0c2b99327a
@ -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);
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user