Detect external file modifications immediately, matching Notepad++ behavior - #1122
Open
PCCV wants to merge 1 commit into
Open
Detect external file modifications immediately, matching Notepad++ behavior#1122PCCV wants to merge 1 commit into
PCCV wants to merge 1 commit into
Conversation
…havior - Add centralized QFileSystemWatcher in EditorManager to detect external file changes without waiting for tab switch or window focus - Reliably trigger the check on window (re)activation via QEvent::ActivationChange (covers X11/Cinnamon gap in existing applicationStateChanged mechanism) - Warn the user before discarding unsaved changes when reloading a file modified externally
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Closes #558.
Currently, NotepadNext only detects that a file was modified by another program when the tab is activated or the window regains focus (checkFileForModification() called only from activateEditor() and focusIn()). This means changes made externally can go unnoticed for a long time if the user stays on the same tab with the window in the background.
This PR adds a centralized QFileSystemWatcher in EditorManager to detect external modifications immediately, without waiting for a tab switch or focus change — matching Notepad++'s behavior.
Changes
Known limitation
QFileSystemWatcher stops watching a file if it's replaced via atomic rename (as some editors/tools do on save). A best-effort re-arm (addPath if the path dropped out of fileWatcher->files()) is included, but this hasn't been exhaustively tested against every external tool's save strategy.
Tested