STR:
1. Open a network file.
2. Close Notepad++ to have it in the session.
3. Disconnect the network, and launch Notepad++ immediately.
4. Around more than 1 minute's delay, then the "Error" dialog displayed.
The reason for the hanging is that the network file was incorrectly detected by doesFileExist (GetFileAttributesEx) as present, leading Notepad++ to attempt opening a non-existent file with _wfopen. This issue seems to stem from a caching mechanism within the IO function (GetFileAttributesEx). When the network disconnects, the cache is not immediately cleared, causing GetFileAttributesEx to falsely report that the file exists. Consequently, when Notepad++ is launched after a network disconnection, GetFileAttributesEx retains its cache, indicating the file exists, while _wfopen fails to locate the network resource, resulting in a hang.
Unfortunately, there's no efficient solution for this problem. The commit's remedy is to check if the file is on the network and whether its directory still exists. If the directory doesn't exist, we avoid calling _wfopen. We verify the directory's existence instead of the file itself because the cache issue with GetFileAttributesEx occurs before _wfopen is executed. Checking the directory avoids the cache problem due to the identical argument being used.
I've tested this remedy in debug mode, and it works fine. However, the problem persists in release mode. Despite this, I believe it's worth keeping this solution, as it provides some protection in a variable network environment, potentially mitigating the issue when it arises.
Ref: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/15658#issuecomment-2386662974
Improve #4306, #6178, #8055, #11388, #12553, #15540, close#15701
This PR prevent hanging when user: Open a network file, modify it. Disconnect the network, then save the file.
It also prevents the zombie process due to blocked CreateFile left behind.
Remove the timeout thread for CreateFile to prevent the zombie process. Use another way for the detection:
If the result of network file existent detection is false, and the network problem found (timeout reached), we just stop and don't call CreateFile routine.
Ref: 1445487
Improve #4306, #6178, #8055, #11388, #12553, #15540
Add thread for CreateFile to fix saving disconnected network file hanging.
STR: Open a network file, modify it. Disconnect the network, then save the file. A huge latency (more than 1 minute) can be observed.
Not that the crash is not reproducible anymore by this PR. If any crash happens for you, please let me know (with the STR).
Ref: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/15669
Improve #4306, #6178, #8055, #11388, #12553, #15540Close#15679
Context: While the network file is disconnected, it's considered non-existent and might to be deleted.
The reason of crash:
"doClose" on the same buffer happens twice while users clicks X button, then chooses "No" when they are asked whether if this file should be kept in editor.
Explanation:
When user clicks X button on the tab of the file in question to close it, "activateBuffer" is called, then "fileClose" is called.
* activateBuffer: Following "activeateBuffer" call in the depth, "checkFileState" is invoked - that leads the message "The file "xxxxxx" doesn't exist anymore. Keep this file in Editor?". If user clicks on No, "doClose" will close the tab and destroy the buffer.
* fileClose: in "fileClose" call, "doClose" will be invoked and try to close the already-destroyed buffer.
Solution:
Retrieve the buffer ID once again, after "activateBuffer" call, for comparing with old buffer ID. If the buffer was destroyed, the new retrieved buffer ID is not the same.
Note: this commit fixes the crash, but it doesn't fix the misbehaviour: If user clicks on "Yes" to answer the message "The file "xxxxxx" doesn't exist anymore. Keep this file in Editor?", the tab will be still closed.
Fix#15684, close#15685
Refactoring for reducing the I/O calls, fix typos.
Reduce the startup time (while the a dirty disconnected network file is in the session) from about 12-15 seconds to about 6 seconds (on my laptop).
Note that there are 2 cases are not improved by the commit:
* STR 1: Open a network file, modify it. Disconnect the network, then save the file.
There will be a huge hanging time (around 1 minute) to get the warning dialog.
I tried to remedy with thread for CreateFileW in the constructor of Win32_IO_File, however it leads crash due to the lock guard in the caller.
* STR 2:
1. Open a network file.
2. Close Notepad++ to have it in the session.
3. Disconnect the network, and launch Notepad++ immediately.
4. Around more than 1 minute's delay, then the "Error" dialog displayed.
The reason of hanging is that the network file was detected by "doesFileExist" as true, so Notepad++ was trying to open non-existent file (by _wfopen).
I believe that there's some kind of cache during the very short period for the IO function (here's our case GetFileAttributes), and such cache is not immediately synchronized (cleared) while network disconnected. As a result, when we launch Notepad++ after the disconnection of network, GetFileAttributes keeps its memory & responds "FileExists". However for _wfopen it doesn't see the resource of network anymore - that makes hanging.
Ref #15658
Improve #4306, #6178, #8055, #11388, #12553, #15540Close#15669
The issue is due to WinAPI's GetFileAttributes function can take a huge amount of time in various situations, like when the target server being offline (usalally).
The current solution is to wait at least 3 seconds for each GetFileAttributes function, then return the default value in case of the problem (or the returned value of the function, in case of normal situation - if it has been executed completely during the 3 seconds).
So there'll still be the hanging time (3 or 6 seconds) while the problem of network connection, but the hanging time (it could be 30 seconds more) is reduced considerablly.
"Wow64EnableWow64FsRedirection" call is also removed from x64 build (in which this call is unnecessary) in this commit to reduce the IO calls.
Fix#4306, fix#6178, fix#8055, fix#11388, fix#12553, fix#15540, close#15658
Note: while create the new tab (empty & clean), there will be a created time displayed. When the document is modified and period backup feature is enabled, a new created time will be assigned and displayed. However, the time of the first modification which makes empty document dirty will be remained as the tab creation time, even with several modification afterward.
Fix#15563, close#15651
Update translation texts for these commits:
* Make C-Like indent deactivatable (439bbb0)
* Improve description for settings "Backup" (108b9f0)
* Add missing localization for debug info dialog and print error (ea5e36a)
Close#15455
Fix Notepad++ Debug binary crash issue while opening some special files (crash after some "Assertion fail" message boxes).
Only the Debug binary is impacted. There's no issue for the release binary, so it's not a "security vulnerability".
Also there's no buffer overflow as the description in CVE-2014-9456.
Fix#12669
Add new plugin notification NPPN_NATIVELANGCHANGED when the native language has been changed, and add new plugin message NPPM_GETNATIVELANGFILENAME for plugins calling after getting NPPN_NATIVELANGCHANGED notification.
Usage of the command:
#define NPPM_GETNATIVELANGFILENAME (NPPMSG + 116)
// int NPPM_GETNATIVELANGFILENAME(size_t strLen, char* nativeLangFileName)
// Get the Current native language file name string.
// Users should call it with nativeLangFileName as NULL to get the required number of char (not including the terminating nul character),
// allocate commandLineStr buffer with the return value + 1, then call it again to get the current native language file name string.
// wParam[in]: strLen is "commandLineStr" buffer length
// lParam[out]: commandLineStr recieves all copied native language file name string
// Return the number of char copied/to copy
Usage of the notification:
#define NPPN_NATIVELANGCHANGED (NPPN_FIRST + 31) // To notify plugins that the current native language is just changed to another one.
// Use NPPM_GETNATIVELANGFILENAME to get current native language file name.
// Use NPPM_GETMENUHANDLE(NPPPLUGINMENU, 0) to get submenu "Plugins" handle (HMENU)
//scnNotification->nmhdr.code = NPPN_NATIVELANGCHANGED;
//scnNotification->nmhdr.hwndFrom = hwndNpp
//scnNotification->nmhdr.idFrom = 0; // preserved for the future use, must be zero
Fix#15513, close#15582
Fix mismatched SCI_BEGINUNDOACTION:
When there is a SCI_BEGINUNDOACTION without the corresponding SCI_ENDUNDOACTION, it then causes that a single undo reverts many changes in at once.
Fix#9426, close#15577
Avoid linux issue:
../src/WinControls/DoubleBuffer/DoubleBuffer.cpp:18:10: fatal error: CommCtrl.h: No such file or directory
18 | #include <CommCtrl.h>
| ^~~~~~~~~~~~
Close#15566
Release 5.5.2 ( https://www.scintilla.org/scintilla552.zip )
Released 21 August 2024.
Add SCI_SETCOPYSEPARATOR for separator between parts of a multiple selection when copied to the clipboard. Feature #1530.
Add SCI_GETUNDOSEQUENCE to determine whether an undo sequence is active and its nesting depth.
Add SCI_STYLESETSTRETCH to support condensed and expanded text styles.
Add SCI_LINEINDENT and SCI_LINEDEDENT. Feature #1524.
Fix bug on Cocoa where double-click stopped working when system had been running for a long time.
On Cocoa implement more values of font weight and stretch.
Release 5.4.0 ( https://www.scintilla.org/lexilla540.zip )
Released 21 August 2024.
Inside Lexilla, LexerModule instances are now const. This will require changes to applications that modify Lexilla.cxx, which may be done to add custom lexers.
Lexer added for TOML "toml".
Bash: Handle backslash in heredoc delimiter. Issue #257.
Progress: Fix lexing of nested comments. Pull request #258.
Force lower-casing of case-insensitive keyword lists so keywords match in some lexers. Issue #259.
Close#15564
Improve Styler Configurator modification application performance considerably.
While one of dockable Panels (Folder as Workspace, for example) is loaded heavily, any action (checkboxes & comboboxes) on Styler Configurator reacts very slowly - for example, check "Bold" in "Font Style".
This commit makes difference among the operations, and optimizes each action in Styler Configurator.
Fix#12436, close#15560
When "User-defined keywords" field has been set keywords, removing all keywords then saving doesn't have any change (the keywords are kept after saving). The commit fix it.
Fix#15543, fix#14303
Add new SubStyles and their available keyword lists to specific languages:
- Enable 8 Scintilla's SubStyles (each), which allow for new keyword lists and styles for the languages with SubStyles available: ActionScript, ASP, Bash, C, C++, C#, GDScript, Go, HTML, Java, JavaScript (standalone and embedded), JSP, Lua, PHP, Python, Resource (RC), Swift, TypeScript, and XML.
- The new SubStyles have been added to `langs.model.xml`, `stylers.model.xml`, and the themes, which means users can just use the StyleConfigurator for the SubStyles, just like they do for the original Styles.
Fix#15520, close#15537
Release 5.5.1 ( https://www.scintilla.org/scintilla551.zip )
Released 22 July 2024.
SCI_CUTALLOWLINE added which is similar to SCI_COPYALLOWLINE but also deletes the copied text. Feature #1518.
Can set font used for autocompletion lists with SCI_AUTOCSETSTYLE. Feature #1523.
Increase maximum zoom set interactively to +60 points. Feature #1517.
Fix flickering cursor after some mouse action sequences. Bug #2443.
Release 5.3.3 ( https://www.scintilla.org/lexilla533.zip )
Released 22 July 2024.
ASP: Control whether ASP is enabled for XML and HTML with lexer.xml.allow.asp and lexer.html.allow.asp. Issue #252.
JavaScript: Recognize regular expressions at start or after '>' in JavaScript when lexer is cpp, hypertext, or xml. Issue #250, Bug #918.
JavaScript: Recognize initial #! 'shebang' line as a comment in standalone files. Issue #253.
Lua: Fix non-ASCII identifiers joined with '.' or ':'. Issue #242.
Lua: Fix folding for multi-line SCE_LUA_LITERALSTRING and SCE_LUA_COMMENT when performed incrementally. Issue #247.
PHP: Control whether PHP is enabled for XML and HTML with lexer.xml.allow.php and lexer.html.allow.php. Issue #252.
Close#15466
Syncronize Paste and Undo commands with file buffer read-only status.
Previously, after e.g. removing the read-only flag, file editing was possible immediately, but Ctrl-V was not. At least a cursor movement or switching between the N++ tabs or apps-switching was required (SCN_UPDATEUI message generated...).
Fix https://github.com/notepad-plus-plus/notepad-plus-plus/issues/13742#issuecomment-2233570312, close#15452
Now Notepad++ ensures that the Folder as Workspace treeview sorting will be ok even for the *nix (Samba, WebDAV, WSL..) storage used.
Fix#10557, fix#15397, close#15457
Add one more option for auto-indent so user can choose among "none", "basic" & "advance".
Also add the indentation section in Preferences dialog.
Fix#15396, close#15414