-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Closing a second buffer makes the cursor jump to the beginning of the first buffer #1186
Comments
/cc @cole-h |
A not-so-short background on this feature, first: Closing a document with So basically, the problem can be traced back to the fact that we indiscriminately close views instead of doing some "smarts" in order to preserve the views. I'll look into improving this. |
I think the issue described here is saying that views other than the one that was closed are moving to the top of their respective documents. In other words, if you have documents A, B, and C open, and you close C, both A and B scroll up to the top of the file for some reason. |
Yes, that is exactly the behavior I'm observing. Maybe I didn't described that clearly enough. The behavior of centering the cursor in the view when switching back and forth between buffers is also somewhat unexpected but doesn't affect usability too much. Could this be a related issue? |
That's exactly what I'm saying though (maybe it was me who wasn't clear; sorry) -- the current cursor position in a document is tied to the |
Sorry, maybe I don't have a good understanding of the terminology. A "view" is just a window into a document right? So if you have a split buffer on the same document, that's two views right? What we're saying is that the cursor is getting reset in a different document than the one that was just closed. |
Just to clarify, then: do you mean that if you open documents A, B, and C in one single split (e.g. no |
The former. If you open documents A, B, and C in separate single split views, move the cursor down in A and B, then close C, the cursors in A and B get reset. |
Right, OK. I'll do my best to explain in detail why this is happening (but basically know that: this is expected behavior with the current implementation). (TL;DR: This is expected and we are indeed talking about the same thing.) Every helix/helix-view/src/editor.rs Lines 492 to 506 in c08d2fa
This means that if you have a helix instance that looks like:
(where If you were to execute Now, if you had a helix instance that looks like the following (assuming "A" was opened in the top split before switching to "B", and then helix was split a couple times):
and then ran
This is the crux of the issue. Notice how document "A" is now a part of Does that help explain a little bit? |
We are not talking about a scenario where we open A, B, and C, and then change A's view to look at C. The scenario that's happening now is, say we open 3 files with
then scroll down A, switch to B, scroll down, switch focus to C
And then Edit: unless I'm misunderstanding how these transitions happen. If you are in view 1 and then do a switch buffer to B, does it change to view 2, or does it swap the documents of view 1 and 2? And if you open 3 files like that, does it make 3 views, or just 1 view and keep the other files open in the background, and switching buffers just reuses view 1? |
@dead10ck wrote:
How I understood @cole-h's explanation it is the later. @cole-h wrote:
I think so. But that leads me to another question: Suppose we do:
than we do:
than we do:
How is the selection in |
If you are looking at a single document A and open a new document B, document B replaces document A in that view (so, the previously-visible document A is now stored somewhere else). The view stays the same, but now document B is visible, and document A is "hidden". Could you make make an asciinema or something? I can't reproduce this. I opened helix and then ran the following:
and the cursors in
Each document has its own list of selections tied to the Maybe something I didn't make clear is: if a document is visible in all views, then all views will be closed, and a new view will be created. This means this new view has a new ID, and as such, helix won't find any matching selections. |
Yeah, OK, that's exactly what I was talking about, thanks. Closing |
Ahhh, I see, so then yeah, doing Sorry for the confusion, I'm still learning how everything works. Thanks for taking the time to explain! |
Previously, when closing buffer, you would loose cursor position in other docs. Also, all splits where the buffer was open would be closed. This PR changes the behavior, if the view has also other buffer previously viewed it switches back to the last one instead of the view being closed. As a side effect, since the views are persisted, the cursor history is persisted as well. Fixes: helix-editor#1186
* feat(commands): better handling of buffer-close Previously, when closing buffer, you would loose cursor position in other docs. Also, all splits where the buffer was open would be closed. This PR changes the behavior, if the view has also other buffer previously viewed it switches back to the last one instead of the view being closed. As a side effect, since the views are persisted, the cursor history is persisted as well. Fixes: #1186 * Adjust buffer close behavior * Remove closed documents from jump history * Fix after rebase
Reproduction steps
(switching back and forth with
gn
centers cursor in view)(expected: cursor stays at downward position)
Environment
~/.cache/helix/helix.log
The text was updated successfully, but these errors were encountered: