-
-
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
Apply transactions to all views #4733
Merged
archseer
merged 4 commits into
helix-editor:master
from
the-mikedavis:md-apply-transactions-to-all-views
Nov 23, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6e423bb
Add a test case for updating jumplists across windows
the-mikedavis f650ce0
Apply transactions to all views on history changes
the-mikedavis 8f08375
Leave TODOs for cleaning up View::apply
the-mikedavis 187858f
Use Iterator::reduce to compose history transactions
the-mikedavis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,29 @@ async fn test_split_write_quit_same_file() -> anyhow::Result<()> { | |
|
||
Ok(()) | ||
} | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn test_changes_in_splits_apply_to_all_views() -> anyhow::Result<()> { | ||
// See <https://github.com/helix-editor/helix/issues/4732>. | ||
// Transactions must be applied to any view that has the changed document open. | ||
// This sequence would panic since the jumplist entry would be modified in one | ||
// window but not the other. Attempting to update the changelist in the other | ||
// window would cause a panic since it would point outside of the document. | ||
|
||
// The key sequence here: | ||
// * <C-w>v Create a vertical split of the current buffer. | ||
// Both views look at the same doc. | ||
// * [<space> Add a line ending to the beginning of the document. | ||
// The cursor is now at line 2 in window 2. | ||
// * <C-s> Save that selection to the jumplist in window 2. | ||
// * <C-w>w Switch to window 1. | ||
// * kd Delete line 1 in window 1. | ||
// * <C-w>q Close window 1, focusing window 2. | ||
// * d Delete line 1 in window 2. | ||
// | ||
// This panicked in the past because the jumplist entry on line 2 of window 2 | ||
// was not updated and after the `kd` step, pointed outside of the document. | ||
test(("#[|]#", "<C-w>v[<space><C-s><C-w>wkd<C-w>qd", "#[|]#")).await?; | ||
Comment on lines
+133
to
+152
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❤️ |
||
|
||
Ok(()) | ||
} |
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: mouse clicks can also change view focus and are handled separately further below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, this will apply as soon as changes are added to history, I thought it was when focus is changed 👍🏻