-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Is there an existing issue for this?
- I have searched the existing issues
Description of the Issue
Notepad++ seems to no longer be clearing its internal file-modified flag for files resulting in continuous updates of its backup files
Notepad++ has a feature where it maintains backup files in %APPDATA%\backup. This is enabled by default and by default Notepad++ checks every 7 seconds and updates the backup file if the user file has been modified since the last check.
If someone modifies a file then Notepad++ will notice this during its periodic checks for dirty files and will either create or update the backup file for the user's file.
This behavior changed starting with Notepad++ version 8.7.1 and the new behavior still exists in v8.7.7.
If a file has been modified since notepad++.exe has been started then notepad++ now updates the backup file on every single periodic check for modified files. That is a puzzle as there is there is no need to update the backup file because the user file has not changed
The continuous updating of the backup file only happens for the active tab. If you switch to another tab that has not been modified then Notepad++ stops continuously updating the backup file. If you switch back to the modified file then Notepad++ resumes the continuous updating of the backup file.
Steps To Reproduce
The issue impacts both x32 and x64 and installed and portable versions. For testing I unzipped the file for a portable version and run it using
c:\npp\x.8.7.7.RTM\notepad++.exe -multiInst -noPlugin c:\tmp\tmp1 c:\tmp\tmp2
c:\tmp\tmp1 was my "dirty" file and I left c:\tmp\tmp2 clean so that I could watch what happens when I switch tabs.
I was watching notepad++.exe's activity using Sysinternals Process Monitor with a filter set to only log activity by the process named notepad++.exe
Current Behavior
Notepad++ is continuously updating its backup file even though the user is not making changes.
Expected Behavior
Notepad++ should only update a backup file when changes are made to to a user file. Once the user file has been saved to the backup then there is no need for Notepad++ to update the backup file until it detects that the user file has been modified again.
Debug Information
Notepad++ v8.7.7 (64-bit)
Build time : Feb 6 2025 - 03:19:13
Path : c:\npp\x.8.7.7.RTM\notepad++.exe
Command Line : -multiInst -noPlugin c:\tmp\tmp1 c:\tmp\tmp2
Admin mode : OFF
Local Conf mode : ON
Cloud Config : OFF
Periodic Backup : ON
Placeholders : OFF
DirectWrite : ON
Multi-instance Mode : monoInst
File Status Auto-Detection : cdEnabledNew (for current file/tab only)
Dark Mode : OFF
OS Name : Windows 11 Home (64-bit)
OS Version : 23H2
OS Build : 22631.4890
Current ANSI codepage : 1252
Plugins : noneAnything else?
More details:
In the Settings / Preferences / Backup section Trigger backup on modification defaults to 7 seconds. If I change this to something else, such as 10 seconds, then Notepad++ starts saving the backup file every 10 seconds. A setting of 1 is allowed and Notepad++ is writing the backup file once a second.
If I turn off Enable session snapshot and periodic backup then Notepad++ stops the continuous updating of the backup file.
This only happens if a file has been modified since notepad++.exe has been started. In other words, if you modify a file then the tab turns red and Notepad++ starts continuously updating the backup of that file when it's the active tab. If you then exit and restart Notepad++, then Notepad++ reloads the file from the session backup. It's shown with a red tab which is correct. Notepad++ is also no longer continuously updating the backup file. If you then make a change to the file then the continuous backups resume.
"undo" does not clear a file's internal modified state. For example, you modify a file, which turns the tab red, exit Notepad++, restart Notepad++, then the tab still shows as red and the backup file is not continuously updated. If you modify the user file then the continuous backups resume. If you then do Ctrl-Z to undo your recent changes Notepad++ still continuously updates the backup for that file.
Versions 8.6.9 and 8.7 do not show this behavior. When a file gets modified then it is saved to the Notepad++'s backup folder once and there are no more updates to the backup file until the user changes the file. Notepad++ then updates the backup file and then goes quiet.
Please see https://community.notepad-plus-plus.org/topic/26595/new-api-to-fix-eventual-regression-regarding-scn_modified-for-some-plugins/12 for a forum thread about this