Feature/remember scroll position #115
Merged
+26
−9
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.
Problem
When switching between tabs the scroll position is lost.
Solution
We need to make sure when an editor is rendered, it scrolls back to where it was.
The
state.openFilesobjects have the instance of choo's component under theeditorproperty.Each choo component stores their own state independently of the main application state, so it makes sense to store the scroll position there instead of the main state.
Not cool
I think there is an edge case with large files that they take some time to fully load and that messes
The scroll listener and
scrollToare made in a timeout callback because I can't find out how to get areadyevent from CodeMirror. 🤷Extra
I noticed that the tab wasn't being selected when you click on the device icon (cables or computer) so I wrote a little fix for that too.