Skip to content

Editor Restoration #2078

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

Merged
merged 21 commits into from
Jul 10, 2025

Conversation

thecoolwinter
Copy link
Collaborator

@thecoolwinter thecoolwinter commented Jul 3, 2025

Description

Implements editor restoration, helping ease the user experience for longer editing tasks spanning multiple files. Users expect opened tabs to retain the scroll position, cursors, and undo stack. To facilitate this, we receive a stream of state updates from the editor and save them to a SQLite DB. When a file is opened again, the state is restored from that DB.

Ideally this is transparent to the user. However, there is one very slight UX flaw that this doesn't address: highlighting. When a user restores an editor there can be a flash as the highlighter works to do syntax highlighting on the newly opened editor. Some potential future directions:

  • The text storage object that outlives editors does retain color information, if we could avoid wiping that color information when an editor is loaded we could avoid that slight delay.
  • To do that, we need to store that state with the storage object somehow. Either through a custom text attribute (could be finicky) or maybe by subclassing NSTextStorage and adding a flag.

Note

This includes a mechanism for sharing undo stacks for editors during a workspace's lifetime. As @austincondiff mentioned on discord, it should add a undo frame when a file is updated externally. This PR notably does not include that change. I'll be adding it in #2075

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Screen.Recording.2025-07-07.at.11.34.26.AM.mov

@thecoolwinter thecoolwinter marked this pull request as draft July 3, 2025 17:49
@thecoolwinter thecoolwinter marked this pull request as ready for review July 3, 2025 21:02
0xWDG
0xWDG previously approved these changes Jul 7, 2025
austincondiff
austincondiff previously approved these changes Jul 9, 2025
@thecoolwinter thecoolwinter dismissed stale reviews from austincondiff and 0xWDG via f258d3a July 10, 2025 16:50
@thecoolwinter thecoolwinter merged commit 4ce9be0 into CodeEditApp:main Jul 10, 2025
2 checks passed
@thecoolwinter thecoolwinter deleted the feat/editor-restoration branch July 10, 2025 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ Save and Restore Editor State
3 participants