Add reload action for open files - #2948
Devanshu-174 wants to merge 1 commit into
Conversation
|
| const value = await fs.readFile(this.encoding); | ||
|
|
||
| this.session.setValue(value); | ||
|
|
||
| this.markLoaded({ |
There was a problem hiding this comment.
If the user types while the file read is pending, the unsaved-change check has already passed. Reload then replaces those edits and marks the file clean without warning. Recheck the document before replacing it. How this was verified: Editor changes mark the file unsaved during the awaited read, but the subsequent replacement and markLoaded clear that state without another check.
| {{#file_on_disk}} | ||
| <li action="reload"> |
There was a problem hiding this comment.
This condition also shows Reload on image, audio, and video tabs because they have file URIs. Those tabs have no editor session to refresh, and the reload method does not rebuild their displayed media. Selecting Reload therefore does not update the file the user sees. Restrict the action to editor files or add a media reload path.
|
|
||
| const value = await fs.readFile(this.encoding); | ||
|
|
||
| this.session.setValue(value); |
There was a problem hiding this comment.
Replacing the document here does not retain the cursor position, so someone reloading while working at a particular line can lose their place. The existing disk-change reload saves and restores the cursor; manual reload should do the same.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
What changed
Added a Reload option for files that exist on disk.
Behavior
Testing
Fixes #2390