Commit Graph

19 Commits (b935fac9576cf333e22b82e40da8c4d73c8e547d)

Author SHA1 Message Date
Blaž Hrastnik f88c077f99 Replace tendril with smartstring
Slightly smaller API surface, less dependencies.
2 years ago
Omnikar f064894e57
Fix Clippy lints in tests (#1563)
Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2 years ago
Skyler Hawthorne 56a9ce5d83
fix(auto_pairs): fix auto pairs with crlf (#1470)
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
3 years ago
Skyler Hawthorne 5b4540fc2d
Auto pairs selection (#1254)
* 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
3 years ago
Skyler Hawthorne 94535fa013
Add auto pairs for same-char pairs (#1219)
* 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
3 years ago
Kirawi 92c2d5d3bf
Document more of helix-core (#904) 3 years ago
langbamit 36095326d0
Fix auto pairs return wrong selection (#613) 3 years ago
Nathan Vegdahl 220bc85821 Fix all remaining warnings in helix-core except for two.
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.
3 years ago
Nathan Vegdahl 4efd6713c5 Work on moving code over to LineEnding instead of assuming '\n'.
Also some general cleanup and some minor fixes along the way.
3 years ago
PabloMansanet 86af55c379
Movement fixes, refactor and unit test suite (#217)
* 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
3 years ago
Blaž Hrastnik 0e5b421646 When calculating a new selection, we need to take newly inserted text into account. 3 years ago
Blaž Hrastnik f8844c6811 Implement pair expansion when pressing new line between bracket pairs.
From:
{|}

To:
{
    |
}
3 years ago
Blaž Hrastnik 7e9ea30a0b auto_pairs: move if cursor, extend if selection. 3 years ago
Blaž Hrastnik 015fd2ffa2 pairs: Use token utf8 lengths instead of 1. 3 years ago
Blaž Hrastnik 9a36d2c2a8 wip: Hooks & trigger characters for completion/signature_help. 3 years ago
Blaž Hrastnik 06aca7691c clippy lint 3 years ago
Blaž Hrastnik d0530fb839 Fix a scrolling crash where it would jump past the end of the buffer. 3 years ago
Blaž Hrastnik 73c92a0bc1 Implement m / match_brackets (using tree sitter). 3 years ago
Blaž Hrastnik 71999cce43 Implement auto-pairs behavior for open and close. 3 years ago