aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/selection.rs
Commit message (Collapse)AuthorAge
* Add command to merge consecutive ranges in selection (#5047)DylanBulfin2022-12-23
|
* Use requested direction for new textobject selection rangeMichael Davis2022-10-03
| | | | | | | | | | | | | | | | | | This changes the behavior of operations like `]f`/`[f` to set the direction of the new range to the direction of the action. The original behavior was to always use the head of the next function. This is inconsistent with the behavior of goto_next_paragraph and makes it impossible to create extend variants of the textobject motions. This causes a behavior change when there are nested functions. The behavior in the parent commit is that repeated uses of `]f` will select every function in the file even if nested. With this commit, functions are skipped. It's notable that it's possible to emulate the original behavior by using the `ensure_selections_forward` (A-:) command between invocations of `]f`.
* Fix extra selection with regex anchors (^,$) (#3598)A-Walrus2022-08-31
| | | Also added a bunch of tests to ensure correct behaviour
* Avoid copying fragments (#3136)Matthias Deiml2022-08-04
| | | | | | | * Avoid copying fragments * Add slice / slices method * Better documentation for fragment and slice methods
* Fix initial selection of Document in new viewSkyler Hawthorne2022-06-19
| | | | | | | | | | | When a new View of a Document is created, a default cursor of 0, 0 is created, and it does not get normalized to a single width cursor until at least one movement of the cursor happens. This appears to have no practical negative effect that I could find, but it makes tests difficult to work with, since the initial selection is not what you expect it to be. This changes the initial selection of a new View to be the width of the first grapheme in the text.
* Improve Readability (#2639)Ryan Russell2022-06-01
|
* Fix Clippy lints in tests (#1563)Omnikar2022-01-23
| | | Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* feat(commands): shrink_selection (#1340)Matouš Dzivjak2022-01-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * feat(commands): shrink_selection Add `shrink_selection` command that can be used to shrink previously expanded selection. To make `shrink_selection` work it was necessary to add selection history to the Document since we want to shrink the selection towards the syntax tree node that was initially selected. Selection history is cleared any time the user changes selection other way than by `expand_selection`. This ensures that we don't get some funky edge cases when user calls `shrink_selection`. Related: https://github.com/helix-editor/helix/discussions/1328 * Refactor shrink_selection, move history to view * Remove useless comment * Add default key mapping for extend&shrink selection * Rework contains_selection method * Shrink selection without expand selects first child
* feat(commands): ensure_selections_forward (#1393)Matouš Dzivjak2021-12-29
| | | | | | | | | | | | | * feat(commands): ensure_selections_forward Add command that ensures that selections are in forward direction. Fixes: https://github.com/helix-editor/helix/issues/1332 * Add keybinding for ensure_selections_forward Add `A-:` keybinding for the ensure_selections_forward command. * Re-use range.flip for flip_selections command
* Auto pairs selection (#1254)Skyler Hawthorne2021-12-21
| | | | | | | | | | | | | | | | * use auto pairs with selections Previously, the auto pairs code was converting the user selection into its cursor form, and setting the transaction's selection to that cursor. This has the effect of destroying the user's selection if they type a pair character that gets auto completed. This fixes the code to work with the user's selection, inserting auto pairs where appropriate, but either keeping or extending the user's selection. * use movement::Direction instead of bool * assume 0-width cursor is forward
* Fix surround cursor position calculation (#1183)Gokul Soumya2021-11-29
| | | | | | | | | | | | | | | Fixes #1077. This was caused by the assumption that a block cursor is represented as zero width internally and simply rendered to be a single width selection, where as in reality a block cursor is an actual single width selection in form and function. Behavioural changes: 1. Surround selection no longer works when cursor is _on_ a surround character that has matching pairs (like `'` or `"`). This was the intended behaviour from the start but worked till now because of the cursor position calculation mismatch.
* Fix selection remove doc comment (#1122)ath32021-11-18
|
* Add `remove_selections` command (#1065)Omnikar2021-11-12
| | | | | | | | | * Add `remove_selections` command * Document `remove_selections` * Update helix-term/src/keymap.rs Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* Implement Selection::replace to replace a single rangeBlaž Hrastnik2021-11-06
| | | | | | Fixes #985 Co-authored-by: Daniel S Poulin <crimsonmage+github@gmail.com>
* Update mdbook style and fix unreadable table head (#806)Ivan Tham2021-10-09
| | | | | | The styles are now pulled from upstream styles, some of the changes I submitted it back to upstream. Fix #796
* Implement 'remove_primary_selection' as Alt-,Blaž Hrastnik2021-09-24
| | | | | | This allows removing search matches from the selection Fixes #713
* mouse: Remove verify_screen_coords, refactor primary selection modificationBlaž Hrastnik2021-07-30
|
* Enforce cursor/selection invariants in one place.Nathan Vegdahl2021-07-28
| | | | Rather than per-command like before.
* Add unit tests for some of the new `Range` methods.Nathan Vegdahl2021-07-27
|
* Improve `Range` documentation and organization.Nathan Vegdahl2021-07-27
|
* Collect some common patterns into methods on `Range`.Nathan Vegdahl2021-07-26
|
* Switch to a cleaner range-head moving abstraction.Nathan Vegdahl2021-07-24
| | | | Also fix a bunch of bugs related to it.
* Fix append mode, and make insertion always happen at head of range.Nathan Vegdahl2021-07-23
|
* Calculate the line that the range head is on correctly.Nathan Vegdahl2021-07-22
|
* Fix selections not being modified quite correctly with text edits.Nathan Vegdahl2021-07-21
|
* Fixes for misc bugs with view movement.Nathan Vegdahl2021-07-21
|
* Fix comment toggle command also sometimes toggling the next line.Nathan Vegdahl2021-07-20
|
* Fix various bugs related to goto-end-of-line command.Nathan Vegdahl2021-07-20
| | | | | This also fixes a bug with `Selection::normalize()`, that could result in an out-of-bounds primary index.
* Fix `Selection::push()` to make the pushed range primary.Nathan Vegdahl2021-07-20
| | | | Apparently I accidentally deleted that behavior in the cleanup.
* Fixed primary cursor position calculation to use 1-width semantics.Nathan Vegdahl2021-07-19
| | | | | This had a bunch of knock-on effects that were buggy, such as bracket match highlighting.
* Update surround commands to work with gap indexing.Nathan Vegdahl2021-07-08
|
* Implement `Range::put()` which manages range movements and extensions.Nathan Vegdahl2021-07-08
| | | | | In particular, this wraps the annoying logic involved in keeping the cursor width to 1 grapheme.
* Merge branch 'master' into great_line_ending_and_cursor_range_cleanupNathan Vegdahl2021-07-06
|\
| * Add object selection (textobjects) (#385)Gokul Soumya2021-07-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add textobjects for word * Add textobjects for surround characters * Apply clippy lints * Remove ThisWordPrevBound in favor of PrevWordEnd It's the same as PrevWordEnd except for taking the current char into account, so use a "flag" to capture that usecase * Add tests for PrevWordEnd movement * Remove ThisWord* movements They did not preserve anchor positions and were only used for textobject boundary search anyway so replace them with simple position finding functions * Rewrite tests of word textobject * Add tests for surround textobject * Add textobject docs * Refactor textobject word position functions * Apply clippy lints on textobject * Fix overflow error with textobjects
* | Fix a couple additional `unused` warnings after merge.Nathan Vegdahl2021-07-02
| |
* | Merge branch 'master' into great_line_ending_and_cursor_range_cleanupNathan Vegdahl2021-07-02
|\|
| * Fix all remaining warnings in helix-core except for two.Nathan Vegdahl2021-07-02
| | | | | | | | | | I'm not sure how to address them, because they look like they might be bugs, and code is involved. Will poke the relevant people.
| * Remove #[allow(unused)] from helix-core, and fix unused imports.Nathan Vegdahl2021-07-02
| | | | | | | | Still a bunch more warnings to fix in core, but it's a start.
* | Ensure a minimum selection width on commands that need it.Nathan Vegdahl2021-07-01
| |
* | Make `Selection`'s normalize and transform methods self-consuming only.Nathan Vegdahl2021-07-01
| |
* | Clean up `Selection` to not use so many allocations.Nathan Vegdahl2021-07-01
| |
* | Better validation method APIs for `Range`.Nathan Vegdahl2021-07-01
| | | | | | | | | | This way they do less work, are more specific to what we actually need, and they compose.
* | Add `Range` methods for various kinds of validation.Nathan Vegdahl2021-07-01
| |
* | Change the `Range` type and associated functions to gap indexing.Nathan Vegdahl2021-07-01
|/
* fix: Correctly merge multiple selection ranges togetherBlaž Hrastnik2021-06-30
| | | | Fixes #391
* fix: Select matching at the start of the doc could crash. Fixes #346Blaž Hrastnik2021-06-23
|
* Movement fixes, refactor and unit test suite (#217)PabloMansanet2021-06-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add convenience/clarity wrapper for Range initialization * Test horizontal moves * Add column jumping tests * Add failing movement conditions for multi-word moves * Refactor skip_over_next * Add complex forward movement unit tests * Add strict whitespace checks and edge case tests * Restore formatting * Remove unused function * Add empty test case for deletion and fix nth_prev_word_boundary * Add tests for backward motion * Refactor word movement * Address review comments and finish refactoring backwards move * Finish unit test suite * Fmt pass * Fix lint erors * Clean up diff restoring bad 'cargo fmt' actions * Simplify movement closures (thanks Pickfire) * Fmt pass * Replace index-based movement with iterator based movement, ensuring that each move incurs a single call to the RopeSlice API * Break down tuple function * Extract common logic to all movement functions * Split iterator helpers away into their own module * WIP reducing clones * Operate on spans * WIP simplifying iterators * Simplify motion helpers * Fix iterator * Fix all unit tests * Refactor and simplify * Simplify fold
* Fixing Multiple Panics (#121)Kirawi2021-06-05
| | | | | | | * init * wip * wip
* LintBlaž Hrastnik2021-05-09
|
* Fix overlap calculation.Blaž Hrastnik2021-04-10
|