Open guy038 opened 1 year ago
Luckily, I verified that the multi-lines regex, in free-spacing mode, works correctly in the Find, Replace and Mark dialogs !
sets extended mode and affects
Find:
case IDC_FINDALL_OPENEDFILES
Button: "Find All in All Opened Documents"case IDC_FINDALL_CURRENTFILE
Button: "Find All in Current Document"Find In Files & (as confirmed by guy038) Find In Projects:
case IDD_FINDINFILES_FIND_BUTTON
Button: "Find All"So it is at least four buttons that updates the combo for the search which can transform to literal escapes \r
and \n
and switches to extended mode.
Related: https://github.com/notepad-plus-plus/notepad-plus-plus/commit/e94b452d2aabcecd6ec0d119b08a27cbbb854b82 committed Jun 10, 2009 which apparently fixes a crash by adding the function named FindReplaceDlg::combo2ExtendedMode
.
the search mode have wrongly moved to the Extended (\n, \r, \t, \0, \x...) mode
I complained about this one time and was told that it was expected behavior and by-design. See the rejected #11847. Rereading that now, I see that it was deemed too risky to change for too little gain.
Here's a good one (bug(s)):
Put Guy's text from above into a tab and select it all:
Press Ctrl+f (so that selected text get auto-populated into Find what when Find window appears):
Press Find All in Current Document; see:
There certainly should be 1 hit! Well but maybe not, because the Search results window shows what really was searched for.
Now look at the Find window; it has changed (to match Search results window):
As a user, why do I want it to work this way??
IMO, this "jump to extended mode" thing should probably be dealt with BEFORE anyone looks at Guy's initial complaint in this issue.
Hello, @mpheath,
I re-read your answer carefully and, indeed, you're perfectly right about this bug.
I didn't notice, when posting this issue, that this wrong behaviour also affects two buttons of the Find dialog !
So, my intial post was not complete :-((
Would it be easy enough to fix this bug and allow the multi-lines free spacing
regex mode for all the search dialogs ?
Cheers,
guy038
@guy038
I re-read your answer carefully and, indeed, you're perfectly right about this bug.
I know about the symptoms of the fix. The actual bug that caused the fix to be committed in 2009 not so much that I could find.
I searched SourceForge patches and discussions to find an issue with details of the find in files crash. Closest was notepad++ crashing on find in files though no information to reproduce. Or this NP++ Crashes when doing a "find in files" with no information to reproduce.
Quote from ticket:
i've been using it for a while with no problem. however, starting a few days ago, it crashes every time i try to use this feature.
Seems the bug did not exist before the time of the ticket.
I didn't notice, when posting this issue, that this wrong behaviour also affects two buttons of the Find dialog !
So, my intial post was not complete :-((
The source code shows what the fix affects. If you cannot read the source code and understand it then I guess you tried your best to investigate. I went a little further by viewing the blame part of the code which led me to the 2009 fix.
Would it be easy enough to fix this bug and allow the multi-lines
free spacing
regex mode for all the search dialogs ?
Revert the fix done in 2009 for the Find Replace Dialog.
I reverted the fix locally by commenting the code and compiled with GCC on 2022-12-25.
No crashing while testing on Windows 7. If actual carriage return or line feed characters cause a crash, I do not see it happening.
Much has changed since June of 2009. The Boost library may have been the cause and many fixes have been done with Boost since 2009. Trying to find an issue report at the Boost tracker that fixes this is like trying to find a needle in a haystack. Searching for crash
or newline
finds many tickets.
The fix may have served a purpose in the time period of 2009 to contain the crash, though it may not be needed anymore.
Perhaps the maintainer could do a temporary revert of the fix which could be trialed for a period of time and reapply the fix if needed.
Compiled Notepad++ from source with the fix reverted. All tests are multiple line selection which are automatically added to the combo.
@mpheath Would your proposed reversion of the "fix" include preventing the automatic switch to Extended Search mode? I think so, but thought I'd ask.
@alankilborn
This code excerpt does the automatic switch to Extended search mode
which is within the combo2ExtendedMode
function of the fix. Revert the fix will remove the transformation of actual carriage return to \r
, actual line feed to \n
and remove the automatic switch to Extended search mode.
Hi, Dear Developers,
Not a critical bug, but ...
Save the modifications using the name
Free_Spacing_Bug.txt
Open the Find in Files dialog (
Ctrl + Shift + F
)Type in
(?x-i) ^ \x20 \x20 abc | ^ \x20 \x20 def
in the Find what : zoneType in
$0
in theReplace with :
zone ( NOT important )Type in
Free_Spacing_Bug.txt
in the Filters : zoneType in the name of the folder, containing the
Free_Spacing_Bug.txt
file, in the Directory : zoneTick the
Wrap around
optionSelect the
Regular expression
search modeExpected behaviour
As soon as you click on the
Find All
button, you get, as expected, theSearch results
windows saying :Now, repeat the same operations but select the four-lines text, below, as the input of the Find what: zone :
Note that this four-lines regex is strictly equivalent to the single line regex
(?x-i) ^ \x20 \x20 abc | ^ \x20 \x20 def
Present behaviour
This time, after a click on the
Find in Files
button, we get :NO hits occurred. In addition, the search mode have wrongly moved to the
Extended (\n, \r, \t, \0, \x...)
modeExpected behaviour :
We should get the same result as above
Important :
This wrong behaviour also occurs if you select the
Find in Projects
dialogLuckily, I verified that the multi-lines regex, in free-spacing mode, works correctly in the
Find
,Replace
andMark
dialogs !This wrong behaviour, when using the
Find in Files
dialog, exists from a very long time ( at least since the6.8.1
version and probably since the adoption of the newPRCE
regex engine, in Notepad++v6.0
, which allows the free-spacing regex mode )If you use a one-line regex, in free-spacing mode , everything is OK in ALL cases
Best Regards,
guy038