-
-
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
Restore view offset when switching buffers with multiple windows #7568
Conversation
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.
This is looking good to me. I'll test it for a while to make sure the behavior feels right
pub fn view_data(&mut self, view_id: ViewId) -> &ViewData { | ||
self.view_data.entry(view_id).or_default() | ||
} | ||
|
||
pub fn view_data_mut(&mut self, view_id: ViewId) -> &mut ViewData { | ||
self.view_data.entry(view_id).or_default() | ||
} |
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.
I wonder if these should return Option<&[mut ]Viewdata>
instead? That would allow us to drop the Default requirement for ViewData
. It's not currently useful to do that between this and #6198 though so I don't have a strong opinion either way
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.
Thus still hast Adressen the issue about mapping view position trough changes. If you edit the buffer in another split the view offset would change. So deleting text in another view causes the position to slide up.
This idea was to entirely replace view.offset with the ViewPosition introduced in this PR (since that fixes other oddities that I ran into) but it's a larger change that can be kept separate.
For reference see where we update selections when there are changes to a document: helix/helix-view/src/document.rs Lines 1160 to 1167 in d570c29
diagnostics: helix/helix-view/src/document.rs Lines 1222 to 1252 in d570c29
and inlay hints: helix/helix-view/src/document.rs Lines 1262 to 1270 in d570c29
|
Since it doesn't seem like @t-monaghan is coming back for this, and I'm blocked on it for #9143, I decided to take a stab at it. I successfully implemented mapping the It works, and solves the issue, but I'm not happy with it. Now every time any function needs to access a I'm starting to think that creating @the-mikedavis @pascalkuthe, I would appreciate if you have any guidance/insights to share on this |
this is not possible you can't access views from I plan to remove document and view as separate structs entirely in the future. Separating them to begin with was fairly pointless since nearly all fields are public so there is little to no encapsulation to begin with (for example the jumplist is a gift that keeps on giving more and more crashes because the laz4y mapping is just not robusta and it can't be encapsulated because it needs to be accessed from document). I want to refactor that so I am not concerned about the extra hashmap lookup, that is basically irrelevant. HasMaps are really really fast. |
Good point.
In that case what I've implemented makes more sense. I'll clean it up and file a new PR. Thanks for the info! |
Closing in favor of #10559 |
This pull request is in response to changes requested by @pascalkuthe in #7414 looking to solve the issue #7355.
The changes made are to ensure views can store and access their own positioning for documents by way of including the field
view_data: HashMap<ViewId, ViewData>
inDocument
.I haven't yet addressed the point of not differentiating between last view position and current view position. I'm unsure how to proceed with this goal.
Fixes #7355