-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add command to extend to line start or end #717
Add command to extend to line start or end #717
Conversation
helix-term/src/commands.rs
Outdated
let (view, doc) = current!(cx.editor); | ||
let text = doc.text().slice(..); | ||
|
||
let selection = doc.selection(view.id).clone().transform(|range| { | ||
let line = range.cursor_line(text); | ||
let pos = line_end_char_index(&text, line); | ||
|
||
range.put_cursor(text, pos, doc.mode == Mode::Select) | ||
range.put_cursor(text, pos, always_extend || doc.mode == Mode::Select) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather see this parameter called extend
, then you can map to the new extend_
commands inside the keymap
helix/helix-term/src/keymap.rs
Line 577 in 918bde0
select.merge_nodes(keymap!({ "Select mode" |
(So two sets of commands, one that always moves, one that always extends)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better than a bool would be if we reused this enum:
helix/helix-core/src/movement.rs
Lines 21 to 25 in 3fda350
#[derive(Copy, Clone, PartialEq, Eq)] | |
pub enum Movement { | |
Extend, | |
Move, | |
} |
918bde0
to
471de01
Compare
@archseer I've updated PR! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! 🎉
Currently,
goto_line_{start,end,end_newline}
commands works asextend
when in select mode. This PR addsextend_to_line_{start,end,end_newline}
commands that always extend to regardless of current mode.