aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/auto_pairs.rs
Commit message (Collapse)AuthorAge
* Fix erroneous indent between closers of auto-pairs (#5330)Triton1712022-12-29
| | | inserting a newline between 2 closers of an auto-pair.
* Fix multi byte auto pairs (#4024)Skyler Hawthorne2022-10-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix test::print for Unicode The print function was not generating correct translations when the input has Unicode (non-ASCII) in it. This is due to its use of String::len, which gives the length in bytes, not chars. * Fix multi-code point auto pairs The current code for auto pairs is counting offsets by summing the length of the open and closing chars with char::len_utf8. Unfortunately, this gives back bytes, and the offset needs to be in chars. Additionally, it was discovered that there was a preexisting bug where the selection was not computed correctly in the case that the cursor was: 1. a single grapheme in width 2. this grapheme was more than one char 3. the direction of the cursor is backwards 4. a secondary range In this case, the offset was not being added into the anchor. This was fixed. * migrate auto pairs tests to integration * review comments
* add conditional noop render backSkyler Hawthorne2022-10-19
| | | | It makes it much slower without stubbing this out
* use main application event loopSkyler Hawthorne2022-06-19
| | | | Use the Application's main event loop to allow LSP, file writes, etc
* 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.
* Configurable auto pairs (#1624)Skyler Hawthorne2022-02-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * impl auto pairs config Implements configuration for which pairs of tokens get auto completed. In order to help with this, the logic for when *not* to auto complete has been generalized from a specific hardcoded list of characters to simply testing if the next/prev char is alphanumeric. It is possible to configure a global list of pairs as well as at the language level. The language config will take precedence over the global config. * rename AutoPair -> Pair * clean up insert_char command * remove Rc * remove some explicit cloning with another impl * fix lint * review comments * global auto-pairs = false takes precedence over language settings * make clippy happy * print out editor config on startup * move auto pairs accessor into Document * rearrange auto pair doc comment * use pattern in Froms
* Replace tendril with smartstringBlaž Hrastnik2022-02-10
| | | | Slightly smaller API surface, less dependencies.
* Fix Clippy lints in tests (#1563)Omnikar2022-01-23
| | | Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
* fix(auto_pairs): fix auto pairs with crlf (#1470)Skyler Hawthorne2022-01-17
| | | | | | | | | | | Auto pairs were resulting in incorrect ranges in the resulting when the line terminators are CRLF (i.e. Windows). It turns out this is because when we were checking if the selection was a single-width cursor, it incorrectly assumed that this would be a single char. This is not the case, as a cursor can cover a multi-code point grapheme. Therefore, we must instead explicitly work with and check graphemes to determine if the cursor should move or extend the selection. Fixes #1436
* 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
* Add auto pairs for same-char pairs (#1219)Skyler Hawthorne2021-12-13
| | | | | | | | | | | | | | | * Add auto pairs for same-char pairs * Add unit tests for all existing functionality * Add auto pairs for same-char pairs (quotes, etc). Account for apostrophe in prose by requiring both sides of the cursor to be non-pair chars or whitespace. This also incidentally will work for avoiding a double single quote in lifetime annotations, at least until <> is added * Slight factor of moving the cursor transform of the selection to inside the hooks. This will enable doing auto pairing with selections, and fixing the bug where auto pairs destroy the selection. Fixes #1014
* Document more of helix-core (#904)Kirawi2021-10-25
|
* Fix auto pairs return wrong selection (#613)langbamit2021-08-18
|
* 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.
* Work on moving code over to LineEnding instead of assuming '\n'.Nathan Vegdahl2021-06-20
| | | | Also some general cleanup and some minor fixes along the way.
* 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
* When calculating a new selection, we need to take newly inserted text into ↵Blaž Hrastnik2021-05-15
| | | | account.
* Implement pair expansion when pressing new line between bracket pairs.Blaž Hrastnik2021-05-06
| | | | | | | | | | From: {|} To: { | }
* auto_pairs: move if cursor, extend if selection.Blaž Hrastnik2021-04-22
|
* pairs: Use token utf8 lengths instead of 1.Blaž Hrastnik2021-04-06
|
* wip: Hooks & trigger characters for completion/signature_help.Blaž Hrastnik2021-03-24
|
* clippy lintBlaž Hrastnik2021-03-24
|
* Fix a scrolling crash where it would jump past the end of the buffer.Blaž Hrastnik2021-03-22
|
* Implement m / match_brackets (using tree sitter).Blaž Hrastnik2021-03-22
|
* Implement auto-pairs behavior for open and close.Blaž Hrastnik2021-03-22