Skip to content
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

feat: save and restore editor view state #1099

Merged

Conversation

pedrolamas
Copy link
Member

@pedrolamas pedrolamas commented May 10, 2023

This PR adds a new Monaco Editor option to "Save and restore view state" (defaults to enabled)

With this option enabled, any file that the user opens will have the current view state (scroll position, selected areas, folds/unfolded regions, ...) stored in the browser local storage when the user closes the editor, and restored when the user re-opens the file.

Video.mp4

To ensure there are no collisions between multi-instances, roots, paths, and filenames, this is the process to generate the state key:

  • Create the "get file" Moonraker API URL (so that will be <moonraker_base_url>/server/files/<root>/<path>/<filename>)
  • Generate an MD5 of this url and encode in Base64 (makes a smaller string)
  • Prepend "monaco."

Fixes #1092

@pedrolamas pedrolamas added the FR - Enhancement New feature or request label May 10, 2023
@pedrolamas pedrolamas added this to the 1.24 milestone May 10, 2023
@pedrolamas pedrolamas requested a review from matmen May 10, 2023 13:28
@pedrolamas pedrolamas force-pushed the pedrolamas/monaco-view-state-save branch from 118bd90 to 5241233 Compare May 10, 2023 14:49
matmen
matmen previously approved these changes May 10, 2023
Copy link
Member

@matmen matmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, LGTM!
Opened pedrolamas#9 for the German translation

@pedrolamas pedrolamas merged commit e0ce11d into fluidd-core:develop May 11, 2023
@pedrolamas pedrolamas deleted the pedrolamas/monaco-view-state-save branch May 11, 2023 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FR - Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an Option to open setting files folded
2 participants