arduino / lab-micropython-editor

Arduino Lab for MicroPython is an Integrated Development Environment (IDE) for MicroPython.
GNU Affero General Public License v3.0
218 stars 29 forks source link

Feature/remember scroll position #115

Closed murilopolese closed 4 months ago

murilopolese commented 5 months ago

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.openFiles objects have the instance of choo's component under the editor property. 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 scrollTo are made in a timeout callback because I can't find out how to get a ready event from CodeMirror. :shrug:

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.