aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/textobject.rs
Commit message (Collapse)AuthorAge
* Make `m` textobject look for pairs enclosing selections (#3344)Daniel S Poulin2023-02-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Make `m` textobject look for pairs enclosing selections Right now, this textobject only looks for pairs that surround the cursor. This ensures that the pair found encloses each selection, which is likely to be intuitively what is expected of this textobject. * Simplification of match code Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * Adjust logic for ensuring surround range encloses selection Prior, it was missing the case where the start of the selection came before the opening brace. We also had an off-by-one error where if the end of the selection was on the closing brace it would not work. * Refactor to search for the open pair specifically to avoid edge cases * Adjust wording of autoinfo to reflect new functionality * Implement tests for surround functionality in new integration style * Fix handling of skip values * Fix out of bounds error * Add `ma` version of tests * Fix formatting of tests * Reduce indentation levels for readability, and update comments * Preserve each selection's direction with enclosing pair surround * Add test case for multiple cursors resulting in overlap * Mark known failures as TODO * Make tests multi-threaded or they fail * Cargo fmt * Fix typos in integration test comments --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* Adjust `m` textobject description and minor code clarification (#3343)Daniel S Poulin2022-08-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Update description of `m` textobject to its actual functionality Sometime recently the functionality of `m` was changed to match the nearest pair to the cursor, rather than the former functionality of matching the pair only if the cursor was on one of the brace characters directly. * Rename surround methods to reflect that they work on pairs The current naming suggests that they may work generally on any textobject, whereas their implementation really focuses on pairs. * Change description of m textobject to match actual functionality The current implementation of `m` no longer merely looks at the pair character the cursor is on, but actually will search for the pair (defined in helix-core/src/surround.rs) that encloses the cursor, and not the entire selection. * Accept suggested wording change Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * Prefix pair surround for consistency Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* Add `m` textobject to select closest surround pairGokul Soumya2022-04-29
|
* Make textobject select last paragraph (#1992)Ivan Tham2022-04-13
| | | | | | | | | | | | | | | | * Make textobject select last paragraph Last paragraph shoud be selected if the cursor was placed on the whitespace paragraph part and `map` is done, otherwise it would do nothing useful, but now we select backwards for the last paragraph which behaves similarly to kakoune, making `map` useful for the last paragraph with whitespace. Example usecase is to copy and paste last ledger cli paragraph quickly by `mapyp` to duplicate last entry. * Fix typo in core textobject Co-authored-by: Michael Davis <mcarsondavis@gmail.com> Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* Remove usage of format ident feature from tests (#2028)Michael Davis2022-04-08
|
* Rename _para to _paragraphIvan Tham2022-04-02
|
* Change test mark from ^@ to #[|]#Ivan Tham2022-04-02
|
* Add paragraph textobjectIvan Tham2022-04-02
| | | | | Change parameter/argument key from p to a since paragraph only have p but parameter are also called arguments sometimes and a is not used.
* Add object.movement for tree-sitter navigationGokul Soumya2022-02-15
|
* 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.
* Add WORD textobject (#991)Omnikar2021-11-08
| | | | | * Add WORD textobject * Document WORD textobject
* Add treesitter textobjects (#728)Gokul Soumya2021-10-23
| | | | | | | | | | | | | | | | | | | | | | | | | * Add treesitter textobject queries Only for Go, Python and Rust for now. * Add tree-sitter textobjects Only has functions and class objects as of now. * Fix tests * Add docs for tree-sitter textobjects * Add guide for creating new textobject queries * Add parameter textobject Only parameter.inside is implemented now, parameter.around will probably require custom predicates akin to nvim' `make-range` since we want to select a trailing comma too (a comma will be an anonymous node and matching against them doesn't work similar to named nodes) * Simplify TextObject cell init
* Fix around-word text-object selection. (#546)Nathan Vegdahl2021-08-06
| | | | | | | | | | | | | * Fix around-word text-object selection. * Text object around-word: select to the left if no whitespace on the right. Also only select around when there's whitespace at all. * Make select-word-around select all white space on a side. * Update commented-out test case. * Fix unused import warning from rebase.
* Fix buggy surround behavior from #376.Nathan Vegdahl2021-08-04
| | | | Fixes #543.
* Address some PR comments.Nathan Vegdahl2021-07-26
|
* Collect some common patterns into methods on `Range`.Nathan Vegdahl2021-07-26
|
* Update surround commands to work with gap indexing.Nathan Vegdahl2021-07-08
|
* Fix surround bug when cursor on same pairGokul Soumya2021-07-03
| | | | | | For example when the cursor is _on_ the `'` in `'word'`, the cursor wouldn't move because the search for a matching pair started _from_ the position of the cursor and simply found itself.
* 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