164 Commits

Author SHA1 Message Date
Don Ho
0ca0348e7f Improve code & refactoring
Close #15681
2024-10-11 19:54:11 +02:00
Don Ho
1445487bb7 Fix network files hanging while the network disconnected (part 3)
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, #15540
Close #15679
2024-10-08 21:08:16 +02:00
Don Ho
d2fb03e41c Make log function easier to be called 2024-10-05 21:47:20 +02:00
Don Ho
a3535f385f Fix network files hanging while the network disconnected (part 2)
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, #15540
Close #15669
2024-10-04 18:04:15 +02:00
Don Ho
f884a39dd4 Fix opened network files hanging issue while the network disconnected
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
2024-10-02 04:52:15 +02:00
Don Ho
b78b3bdef0 Several enhancements for code
Close #15516
2024-08-05 15:40:44 +02:00
Don Ho
4cde33048f Use std::wstring instead of generic_string 2024-07-19 04:35:14 +02:00
Don Ho
0858dfa4af Use GetFileAttributes instead of PathFileExists
Ref: https://github.com/notepad-plus-plus/nppShell/pull/64#discussion_r1664890166
Ref: https://devblogs.microsoft.com/oldnewthing/20071023-00/?p=24713

Fix #14839, close #15400
2024-07-14 22:50:00 +02:00
Don Ho
0842c991d3 Remove ambiguous symbols (part 2)
Replace  TEXT("") and _T('') by the L"".
Follow up 94af271be9

Close #15377
2024-06-29 22:07:21 +02:00
Don Ho
94af271be9 Remove ambiguous symbols
The "ambiguous" symbols (TCHAR & generic_string) are used when Notepad++ suppoted both ANSI & Unicode formats.
Since ANSI format of Notepad++ has been dropped (since long time ago), TCHAR & generic_string will be replaced by wchar_t & wstring respectively.

Close #15371
2024-06-28 18:47:40 +02:00
xomx
982f52224c Add the possibility for opening a shortcut file if change file ext
Do not recognize files without lnk-extension as Windows shortcuts.

Fix also https://github.com/notepad-plus-plus/notepad-plus-plus/pull/15211#issuecomment-2156495651

Fix #9643, fix #11089, fix #10139, close #15364
2024-06-28 18:19:11 +02:00
xomx
3c3e7cdadd Fix Encoding "Convert to..." regression
Fix incorrect Clipboard handling. This commit fixes possibly #9426

Fix #15324, fix #15271, fix #3054, close #15346
2024-06-27 14:54:09 +02:00
Don Ho
89aaf43722 Use standard function (wcscmp/wcsicmp) instead home made one
Close #15030
2024-04-24 02:45:54 +02:00
ozone10
b476c67447 Add new DPI support to hash dialogs
- fix leak because of font.

ref #14959

Close  #15018
2024-04-21 01:53:09 +02:00
Alan Kilborn
2e4ad67dff Refactor FindFirstFile-FindNextFile code blocks
Fix #14853, fix #14847, fix 060396c#r139323315, close #14857
2024-03-14 20:15:14 +01:00
ozone10
9d92b0a869 Fix some gcc warnings
Fix #14845, close #14846
2024-03-09 03:40:04 +01:00
Dmitry
cb1f2d1479 Check NULL pointer while opening filees to prevent Notepad++ from crash
Fix #14131, close #14094
2023-09-17 20:34:25 +02:00
Don Ho
3aa9e9280f Fix session file saving problem if it's read-only
Refactoring and fix a typo.

Fix #14024, fix #13894, fix #13859, close #14035
2023-08-22 13:57:07 +02:00
Don Ho
391f4281ef Fix leading & tailling spaces being allowed after renaming tab issue
Ref: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/13344#issuecomment-1665687932

Fix #13967, close #13967
2023-08-05 18:59:30 +02:00
xomx
9122dc64fa Fix rejection of the standard filenames with dot at the end (regression)
Currently we cannot accept e.g. the "\\?\C:\file.", but when someone tries to open the standard variant 'C:\file.', we should accept that, as this is the way how to work with filenames without an extension.

Fixes #12849, close #13888
2023-07-16 01:54:20 +02:00
Don Ho
9e24ec55db Improve lines sorting memory consumption
Use reference instead of copy for the sorting result.
Also improve lines sorting performance slightly: Sorting a 200 MB text file takes 13.71 seconds instead of 14.63 seconds.

Fix #10435, close #13852
2023-07-02 03:32:55 +02:00
doug1234
81802e7d77 Fix search results output alignment for large file searches
Fix #13481, close #13482
2023-04-10 15:18:43 +02:00
ozone10
4a4f96cefc Code enhancement: Fix GCC warnings
- fix conversion warnings
- fix missing-field-initializers warnings
- fix unused-parameter warnings
- fix deprecated-copy warnings
- add initializers

Fix #13122, close #13123
2023-02-15 21:06:38 +01:00
Don Ho
6e7901ecb3 Fix folder display mess in non-western languges under Macro/Run menu
Fix #12670
2023-01-26 23:32:51 +01:00
Don Ho
535bd8fa0e Use wide char version's function directely (part3)
ref: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/12613#discussion_r1045153278
2023-01-21 21:28:23 +01:00
Don Ho
6140865351 Use wide char version's function directely (part2)
ref: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/12613#discussion_r1045153278
2023-01-19 04:12:29 +01:00
Don Ho
432dcb7f15 Use wide char version's function directely (part1)
ref: https://github.com/notepad-plus-plus/notepad-plus-plus/pull/12613#discussion_r1045153278
2023-01-19 02:52:23 +01:00
Don Ho
3ee8660c23 Replace N++ by Notepad++ and fix some typos
Fix also function "getWinVersionStr" not returning "Windows 11":
https://github.com/notepad-plus-plus/notepad-plus-plus/pull/12722#discussion_r1058510340

Fix #12708, fix #12709
2022-12-29 15:38:20 +01:00
xomx
4f1aa7b004 Fix crash on Win32 Namespace prefixed file name
Implement support for Win32 Namespace prefixed file name in Notepad++.
(Ref: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-file-namespaces)

Support the Win32-filenames escaped by \\?\ or \\?\UNC\, possible globbing in filenames (\\?\C:\fil?.txt) and shell links (\\?\C:\file.txt.lnk) included.

Unsupported (temporarily - it needs further patches for Notepad++):
- any raw filename with length exceeding the MAX_PATH.
- any nonstandard Windows OS filename: with 'dot' or 'space' char(s) at the name end, WinOS reserved ones: AUX, CON, PRN, NUL, COM1-9, LPT1-9 and the ones with invalid ASCII chars in it (0-31, <, >, | , ").

Fix #12453, close #12613
2022-12-14 15:02:04 +01:00
Don Ho
e73fca5a85 Use c++20 function ends_with()
Close #12294
2022-10-06 20:49:23 +02:00
Don Ho
3cbbb42933 Revert "Fix CI system error due to the project build env update"
This reverts commit c64049a1e64f9f8145bcd0847e914f8b05437739.
2022-10-06 14:15:16 +02:00
Don Ho
c64049a1e6 Fix CI system error due to the project build env update
And use C++20 for string::ends_with() function.
2022-10-05 17:28:21 +02:00
SinghRajenM
4b539b4d5d Build project using C++20
Fix #12232, close #12233
2022-10-05 15:44:56 +02:00
ozone10
b29a9ce142 Code enhancement - removing gcc warning
Fix conversion-null, nonnull-compare, dangling-else, address warnings, add initializers.

Fix #12198, close #12199
2022-09-20 16:19:58 +02:00
ozone10
2da5c5b393 Code enhancement
Fix parentheses, misleading-indentation, sign-compare, some conversion-null warnings.

Fix #12139, close #12140
2022-09-11 18:22:51 +02:00
ozone10
2c0134ef5a Add plus and arrow (drop down list of opened files) buttons on menu bar
1. Add plus and arrow buttons on menu bar beside of 'X' button:
   - plus button: for adding a new document
   - arrow button: display a drop down list for all opened files to offer users quick access of switching file
2. Enhance the most recent opened file list: Increase maximun file number to 30.

Fix #11229, close #11757
2022-06-05 15:44:05 +02:00
Don Ho
ddbb75f0f7 Make Plugin Admin exception message more clear 2022-05-25 19:27:18 +02:00
Don Ho
d9c5688635 Fix file saving critical bug under Symantec encryption desktop
Fix #11339, close #11403
2022-03-18 14:32:25 +01:00
Don Ho
f9118dd13c Use plugin list's plugin compatibility info for loading plugins
A new ability for checking plugins' compatibility with running Notepad++ has been added in Plugin List & Plugin Admin (a06b404708).
This PR extends this ability by using Plugin Admin's plugin list to filter plugins to load - if any plugin to load with **the same folder name**, **the same version** (as in the plugin list) and it's **not compatible** with the running Notepad++ version found while loading plugins, it will be skipped for being loaded.

Fix #11353, close #11350
2022-03-07 15:33:36 +01:00
Don Ho
785453147b Inialize all memebers of struct (instead of its 1st member) to zero
The curly brace initiator in C/C++ is quite confusing (at least to me).
The C style array uses {0} for initializing all the array to 0,
whereas C++ struct uses {0} for initializing only the 1st member's value to 0.
If we want to set all members' value in a struct to 0, we should use {} instread of {0}.

This commit fix the error which initialize only the 1st member's value to 0 in the structures.

Ref:
1. https://docs.microsoft.com/en-us/cpp/cpp/initializing-classes-and-structs-without-constructors-cpp?view=msvc-170
2. https://en.cppreference.com/w/c/language/struct_initialization
2022-02-09 16:41:56 +01:00
Don Ho
993506af0a Fix Find in Files crash 2022-01-31 03:55:28 +01:00
Don Ho
961a133a60 Remove 2GB file open restriction for x64 binary
Fix #10921, close #11047
2022-01-25 18:08:05 +01:00
Don Ho
7ebb1e3672 Add Find/Replace text swap button in Find replace dialog
Fix  #6010, close #11037
2022-01-13 18:44:03 +01:00
mere-human
9be4eeb4e6 Add copy name/path commands to DocList and Edit menu
1. Add new commands to copy selected files name/path into multi-selection context menu in Document List.
2. Add new commands to copy all files name/path into Edit > Copy to Clipboard.
3. Create a new function buf2Clipborad() to be used in all similar commands.
4. Fix the translation of the Document List multi-selection context menu.

Fix #10394, close #10993
2022-01-05 15:58:54 +01:00
Don Ho
b5d646b4cd Add exclude folder(s) capacity in Find in Files
This PR allows users to provide the list of excluding folder names/patterns in "Filters" field.
Eclusion operator is alway "!" at the begining. In order to distinguish folder from file, "\" should be used as prefix of the folder name/pattern, following "!". That allows the exclusion of the directories under the root directory you want to search (the 1st level of matched directories).

If users need to exclude folders with the same name (or names matched the specific pattern) in all levels, the + should be put between "!" and "\" to exclude them recursively.

Here is a sample:
Filters: *.* !\bin !+\test !+\log*
Directory: c:\myProject\

So the excluded directories could be:

    c:\myProject\bin\
    c:\myProject\log\
    c:\myProject\logs\
    c:\myProject\src\log4j\
    c:\myProject\test\
    c:\myProject\src\test\

The following directories will not be excluded:

    c:\myProject\foo\tests\
    c:\myProject\foo\bin\

Note that "inclusion of folder" is not allowed, and such pattern will be ignored.

Fix #2433, fix #8350, close #10927
2021-12-21 18:39:22 +01:00
Don Ho
acb8a9db47 Add logs for nul content corruption issue
These logs are written for debugging NUL file-corruption issue (#6133) and session lost issue (#10402) which are still problematic probably.
The writting log info will be triggered only when Windows notifies Notepad++ to end session.
The log file will be in "%APPDATA%\Notepad++\" or in Notepad++ installation folder if doLocalConf.xml is present.
To disable the log, just remove nppLogNulContentCorruptionIssue.xml.

Close #10871
2021-12-04 15:33:32 +01:00
Don Ho
12a13b1c0a Fix saving file and false alert on network drive issues
And add log ability for debugging network drive file status detection issue.

To activate log, user should:
1. Add an empty "nppLogNetworkDriveIssue.xml" file beside of notepad++.exe, or if user has no admin previlege, he/she can add this file into %APPDATA%\Notepad++\.
2. Create "C:\temp\" directory, if it doesn't exist yet.
3. Start notepad++.exe, and wait for the file status (timestamp) detection error from the network drive. If the errors occur, there should be some trace in "C:\temp\nppLogNetworkDriveIssue.log".

People who have had the network drive file status detection issue in #10688, #10753, #10757, #10751 & #10787 are welcome to download the binary and provide the generated log in order to fix this issue.

Fix #10751, fix #10688, fix #10753, fix #10757, fix #10751, fix #10787, close #10847
2021-12-01 20:42:35 +01:00
Christian Grasser
f52c2b022d Fix crash in regex search
Avoid unhandled std::range_error exceptions in case of an text input issue by providing an user-supplied byte-error string
see https://en.cppreference.com/w/cpp/locale/wstring_convert/from_bytes and https://en.cppreference.com/w/cpp/locale/wstring_convert/to_bytes

Fix #10773, close #10783
2021-11-16 00:05:04 +01:00
Ashfaaq18
6526094ee7 Fix tooltip layout and position in RTL mode
Fix #10646, close #10655
2021-10-14 18:15:16 +02:00
Don Ho
682a8edafa CFile (Win32 API IO) Refactoring
1. Rename CFile to Win32_IO_File (plus some modification in class).
2. Add new method writeStr() in Win32_IO_File class to write "char*" & string.
3. Change method names of Utf8_16_Write class and make writeFile() method return accurate type (boolean).

Close #10612
2021-10-02 15:00:08 +02:00