cosmic-edit
cosmic-edit copied to clipboard
Backup Unsaved Changes
Backup Unsaved Changes
(I have tested every text editor in my OS's package manager and none of them are usable because they are missing these features... I have to use Notepad++ through Wine) If a text editor isn't usable like a sticky note app, at some point it is going to delete important information without recovery.
1. Correctly remember opened tabs (as well as a browser):
- [ ] 1.1 Auto-Save open tabs: In human readable file, like JSON or TOML (use Cosmic's default, useful like browser's export bookmarks).
- [ ] 1.2 Auto-Save open tabs: In backup folder, like ~ user folder, not a temp folder.
- [ ] 1.3 Auto-Create unnamed files: (File Menu -> New Text File, creates empty file in Documents folder or same backup folder following naming template like "document3". (Location configurable). Reuse first non-opened empty file using the naming template before creating a new one.
- [ ] 1.4 Unnamed file cleanup: Maybe if an empty unnamed file tab is closed, just delete the empty file using the naming template. (Should be safe in backup folder, but may not always be safe in Documents folder).
- [ ] 1.5 Recover tabs from program crash & OS crash: Save on changes to open tabs, not any closing event as they do not fire on crash.
- [ ] 1.6 Handle double open: Do not double open tabs if the program is ran twice. Do not lose list of open tabs, even if either one, or both open processes are closed in any order.
- [ ] 1.7 Closing Windows:
- Know the difference between user closing a tab, and a close signal from the OS.
- If there is a single window, remember tabs and close program.
- If there are multiple windows, closing a window should give a prompt to "Keep tabs & Exit" or "Close tabs in window". (Configurable). Closing unsaved tabs should each sequentially give a "Save", "Close without Saving", or if needed "Delete Unsaved Document".
2. Backup unsaved changes (as well as Notepad++):
- [ ] 2.1 On keyrelease, X-seconds after change, or after X-seconds of idling after change (Configurable, play nice with linters) update a backup/archive copy of the entire file somewhere in ~ user folder. This would be manually findable and recoverable even if the OS couldn't boot. It should have the same access permissions as the original file for security. Do not wait to save on any closing event as they do not fire on crash.
- [ ] 2.2 With 2.1 also backup a little of the undo history (does not have to be plain text nor manually findable, must survive reboot). It should have the same access permissions as the original file for security.
- [ ] 2.3 After program crash, OS crash, or just program was closed: Recover unsaved changes and backed up undo history.
- [ ] 2.4 Clean up: On save, delete backup file, but keep undo history.
3. Watch for changes (like from formatters):
- [ ] 3.1 Do not change timestamp, if there is no change.
- [ ] 3.2 Watch Files: Detect if another program (formatters/linters) has really changed the file contents (not just a timestamp change). Do not show tab as unsaved if the file content has not really changed.
- [ ] 3.3 Auto-Reload: Load changed file without prompt if only simple changes like additions. (Configurable).
- [ ] 3.4 Compare: If non-simple changes to file are detected: Change tab into a "Compare" tab that shows a side-by-side (diff) with options like: Keep On-disk (left), Keep Unsaved (right), Rename On-disk (left), Rename Unsaved (right). (Configurable auto-selection per file type or maybe project folder).
- [ ] 3.5 Compare Recovery: Menu-option/UI-button to recover/undo if the user clicked the wrong compare button (backup/archive other choice for a bit, must survive a reboot).
4. Misc:
- [ ] 4.1 Copy on write: All file saves should be copy on write, maybe detect if the format of the hard drive enforces it, otherwise do it yourself. Keep backup archives as needed (like ability to recover if the user clicked the wrong compare button). Error on the side of converting to a "Compare" tab instead of deleting changes the user may still want.
- [ ] 4.2 Any unsaved tab has a menu-option/UI-button to be converted into a "Compare" tab that shows a side-by-side with the On-disk file, see 3.4.
5. Far future stretch goal:
- [ ] 5.1 Compare Merge: Also show side-by-side column of automatic merge, that you can directly edit and make choices per conflict. Option: Keep Merge (center). See 3.4.
- [ ] 5.2 Understand the Git merge format, auto-detect it, and open these files in a "Compare" tab, see 3.4.