-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto pair deletions with selections #7269
Open
dead10ck
wants to merge
8
commits into
helix-editor:master
Choose a base branch
from
dead10ck:auto-pair-delete
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dead10ck
force-pushed
the
auto-pair-delete
branch
from
June 7, 2023 23:50
3a4afeb
to
65dd1de
Compare
kirawi
added
C-enhancement
Category: Improvements
A-helix-term
Area: Helix term improvements
labels
Jun 15, 2023
dead10ck
force-pushed
the
auto-pair-delete
branch
from
June 19, 2023 04:10
65dd1de
to
50da07b
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
from
June 25, 2023 03:46
50da07b
to
3c53b35
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
from
July 19, 2023 03:02
3c53b35
to
5c4f5d2
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
from
August 1, 2023 02:41
5c4f5d2
to
32825f0
Compare
pascalkuthe
added
S-waiting-on-review
Status: Awaiting review from a maintainer.
E-medium
Call for participation: Experience needed to fix: Medium / intermediate
labels
Aug 8, 2023
dead10ck
force-pushed
the
auto-pair-delete
branch
from
August 29, 2023 01:27
32825f0
to
693b508
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
from
September 18, 2023 15:07
693b508
to
3d1948a
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
from
October 24, 2023 22:19
3d1948a
to
c3bbdc1
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
from
November 20, 2023 12:31
c3bbdc1
to
5408d6b
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
from
January 27, 2024 00:48
5408d6b
to
c7d2178
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
from
February 29, 2024 14:50
c7d2178
to
6627bff
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
2 times, most recently
from
April 7, 2024 19:40
63992e2
to
22fa4d6
Compare
This was rebased. I think the new tests had been failing since the integration test refactor, but I fixed those too. |
dead10ck
force-pushed
the
auto-pair-delete
branch
from
April 9, 2024 15:25
cc58787
to
38dee58
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
2 times, most recently
from
April 29, 2024 03:14
37c68cb
to
ff3ea3d
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
from
June 18, 2024 18:53
a2b9b23
to
d8724fd
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
from
July 15, 2024 22:29
d8724fd
to
4fb0ff0
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
from
July 28, 2024 01:02
4fb0ff0
to
b709488
Compare
dead10ck
force-pushed
the
auto-pair-delete
branch
from
September 6, 2024 20:57
b709488
to
030e8fa
Compare
Adds `Transaction::change_by_and_with_selection` which centralizes logic for producing change sets with a potentially new selection that is applied incrementally, rather than all at once at the end with `with_selection`. It also centralizes the offset tracking logic so that the caller can construct a new selection with ranges as if they were operating on the text as-is.
Change the auto pair hook to operate on single ranges to allow transactions that mix auto pair changes with other operations, such as inserting or deleting a single char, and denendting.
This completes auto pair deletions. Currently, auto pairs only get deleted when the range is a single grapheme wide, since otherwise, the selection would get computed incorrectly through the normal change mapping process. Now auto pairs get deleted even with larger ranges, and the resulting selection is correct.
dead10ck
force-pushed
the
auto-pair-delete
branch
from
November 2, 2024 20:32
030e8fa
to
9360563
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-helix-term
Area: Helix term improvements
C-enhancement
Category: Improvements
E-medium
Call for participation: Experience needed to fix: Medium / intermediate
S-waiting-on-review
Status: Awaiting review from a maintainer.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR completes auto pair deletions. Currently, pairs are only deleted on ranges that are a single grapheme in width, since the normal change mapping process results in an incorrect selection on multi-grapheme ranges.
This is achieved with two new functions:
change_by_and_with_selection
delete_by_and_with_selection
They are helpers which take a transformation function that produces individual changes, one range at a time, and can optionally produce a new range that replaces the input range that it took as an argument. When one is not given, the input range is mapped through the change set as normal. This allows the caller to apply changes to the text and incrementally build a new selection as they go, picking and choosing in which cases new ranges are computed explicitly, and in which they are mapped normally.
Concretely, this solves the problem of needing auto pair deletes to work concurrently with dedenting on backspace; the auto pair hooks were changed to operate on individual ranges and return individual changes, rather than producing a whole complete transaction. Then deleting was enabled to compose changes from all 3 possible scenarios at once, i.e. deleting a single grapheme, dedenting, and auto pair deletions.
Additionally, this PR inserts an extra whitespace when the cursor is inside a pair to pad the left and right.