Updated to use grapheme helpers

pull/9483/head
Steven 10 months ago
parent 0311256d34
commit 091ec45740

@ -108,39 +108,40 @@ Normal mode is the default mode when you launch helix. You can return to it from
### Selection manipulation ### Selection manipulation
| Key | Description | Command | | Key | Description | Command |
| ----- | ----------- | ------- | |----------------------| ----------- | ------- |
| `s` | Select all regex matches inside selections | `select_regex` | | `s` | Select all regex matches inside selections | `select_regex` |
| `S` | Split selection into sub selections on regex matches | `split_selection` | | `S` | Split selection into sub selections on regex matches | `split_selection` |
| `Alt-s` | Split selection on newlines | `split_selection_on_newline` | | `Alt-s` | Split selection on newlines | `split_selection_on_newline` |
| `Alt-minus` | Merge selections | `merge_selections` | | `Alt-S` | Select first and last characters of each selection | `select_first_and_last_chars` |
| `Alt-_` | Merge consecutive selections | `merge_consecutive_selections` | | `Alt-minus` | Merge selections | `merge_selections` |
| `&` | Align selection in columns | `align_selections` | | `Alt-_` | Merge consecutive selections | `merge_consecutive_selections` |
| `_` | Trim whitespace from the selection | `trim_selections` | | `&` | Align selection in columns | `align_selections` |
| `;` | Collapse selection onto a single cursor | `collapse_selection` | | `_` | Trim whitespace from the selection | `trim_selections` |
| `Alt-;` | Flip selection cursor and anchor | `flip_selections` | | `;` | Collapse selection onto a single cursor | `collapse_selection` |
| `Alt-:` | Ensures the selection is in forward direction | `ensure_selections_forward` | | `Alt-;` | Flip selection cursor and anchor | `flip_selections` |
| `,` | Keep only the primary selection | `keep_primary_selection` | | `Alt-:` | Ensures the selection is in forward direction | `ensure_selections_forward` |
| `Alt-,` | Remove the primary selection | `remove_primary_selection` | | `,` | Keep only the primary selection | `keep_primary_selection` |
| `C` | Copy selection onto the next line (Add cursor below) | `copy_selection_on_next_line` | | `Alt-,` | Remove the primary selection | `remove_primary_selection` |
| `Alt-C` | Copy selection onto the previous line (Add cursor above) | `copy_selection_on_prev_line` | | `C` | Copy selection onto the next line (Add cursor below) | `copy_selection_on_next_line` |
| `(` | Rotate main selection backward | `rotate_selections_backward` | | `Alt-C` | Copy selection onto the previous line (Add cursor above) | `copy_selection_on_prev_line` |
| `)` | Rotate main selection forward | `rotate_selections_forward` | | `(` | Rotate main selection backward | `rotate_selections_backward` |
| `Alt-(` | Rotate selection contents backward | `rotate_selection_contents_backward` | | `)` | Rotate main selection forward | `rotate_selections_forward` |
| `Alt-)` | Rotate selection contents forward | `rotate_selection_contents_forward` | | `Alt-(` | Rotate selection contents backward | `rotate_selection_contents_backward` |
| `%` | Select entire file | `select_all` | | `Alt-)` | Rotate selection contents forward | `rotate_selection_contents_forward` |
| `x` | Select current line, if already selected, extend to next line | `extend_line_below` | | `%` | Select entire file | `select_all` |
| `X` | Extend selection to line bounds (line-wise selection) | `extend_to_line_bounds` | | `x` | Select current line, if already selected, extend to next line | `extend_line_below` |
| `Alt-x` | Shrink selection to line bounds (line-wise selection) | `shrink_to_line_bounds` | | `X` | Extend selection to line bounds (line-wise selection) | `extend_to_line_bounds` |
| `J` | Join lines inside selection | `join_selections` | | `Alt-x` | Shrink selection to line bounds (line-wise selection) | `shrink_to_line_bounds` |
| `Alt-J` | Join lines inside selection and select the inserted space | `join_selections_space` | | `J` | Join lines inside selection | `join_selections` |
| `K` | Keep selections matching the regex | `keep_selections` | | `Alt-J` | Join lines inside selection and select the inserted space | `join_selections_space` |
| `Alt-K` | Remove selections matching the regex | `remove_selections` | | `K` | Keep selections matching the regex | `keep_selections` |
| `Ctrl-c` | Comment/uncomment the selections | `toggle_comments` | | `Alt-K` | Remove selections matching the regex | `remove_selections` |
| `Alt-o`, `Alt-up` | Expand selection to parent syntax node (**TS**) | `expand_selection` | | `Ctrl-c` | Comment/uncomment the selections | `toggle_comments` |
| `Alt-i`, `Alt-down` | Shrink syntax tree object selection (**TS**) | `shrink_selection` | | `Alt-o`, `Alt-up` | Expand selection to parent syntax node (**TS**) | `expand_selection` |
| `Alt-p`, `Alt-left` | Select previous sibling node in syntax tree (**TS**) | `select_prev_sibling` | | `Alt-i`, `Alt-down` | Shrink syntax tree object selection (**TS**) | `shrink_selection` |
| `Alt-n`, `Alt-right` | Select next sibling node in syntax tree (**TS**) | `select_next_sibling` | | `Alt-p`, `Alt-left` | Select previous sibling node in syntax tree (**TS**) | `select_prev_sibling` |
| `Alt-n`, `Alt-right` | Select next sibling node in syntax tree (**TS**) | `select_next_sibling` |
### Search ### Search

@ -1814,11 +1814,12 @@ fn select_all(cx: &mut Context) {
fn select_first_and_last_chars(cx: &mut Context) { fn select_first_and_last_chars(cx: &mut Context) {
let (view, doc) = current!(cx.editor); let (view, doc) = current!(cx.editor);
let text = doc.text().slice(..);
let selection = doc.selection(view.id).clone().transform_iter(|range| { let selection = doc.selection(view.id).clone().transform_iter(|range| {
vec![ [
Range::new(range.anchor, range.anchor + 1), Range::new(range.from(), graphemes::next_grapheme_boundary(text, range.from())),
Range::new(range.head - 1, range.head), Range::new(graphemes::prev_grapheme_boundary(text, range.to()), range.to())
] ]
.into_iter() .into_iter()
}); });

Loading…
Cancel
Save