Wrong insertion of text, in the new FIND and REPLACE dialogs
- 
Hi, All,
Holidays are over and I’m back home. So, let’s resume our discussion. I’m quite sure there are a lot of problems with the new
Search and Replacedialog, in thev8.8.4relaease, because of the new feature :4. Increase search input length from 2046 to 16383.I assume that :
- 
The
Maximum Size for Auto-Checking "In selection", inSettings > Preferences... > Searching, is set to 0 - 
The Search mode of the
Finddialog is set toNormal - 
All other options of the
Finddialog are unckecked 
If I chose these preferences about searching :

And if I consider the text below :
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890- 
Select the first
1,024digits, above, leaving the remainder567890 - 
Open the Find dialog (
Ctrl + F) 
=> You correctly see the first
1,024characters of this single line are filled in the Find field and can be matched again !- 
Close the Find dialog (
Esc) - 
Select the first
1,025digits, above, leaving the remainder67890 - 
Open the Find dialog (
Ctrl + F) - 
Hit the
Deletekey to suppress any text in the Find field ( IMPORTANT ) - 
Close the Find dialog (
Esc) - 
Re-open the Find dialog (
Ctrl + F) 
=> The Find field is totally empty ?!
I would have expected that the first
1,025characters would have been filled in the Find field, because of my preference :Fill Find Field with Selected Text , which is checked
And this should be true from
1,025to16,383digits, which is the new limit !
Can anyone confirm this simple test ?
Note that I found out other oddities, that I will develop later. Everything in its own time !
Best Regards,
guy038
 - 
 - 
 - 
The problem when selecting 1025+ characters as a pre-step is because of this line of code:
FINDREPLACE_INSELECTION_THRESHOLD_DEFAULTis set to 1024, here:Probably the check against that constant should not be made if
Maximum Size for Auto-Checking "In selection", in Settings > Preferences… > Searching, is set to 0. - 
Hello @alan-kilborn and All,
Many thanks, Alan, for detecting the problem : your assumption is surely exact ! So, this is a FIRST bug regarding the
SearchfeatureNow, here is the SECOND bug :
Whatever the search mode chosen, any selected text, up to the limit (
2046or16823), can be pasted in theFind what:zone ( withCtrl + V) ONLY IF that text does not contain anyCRcharacter. As soon as a singleCRcharacter is met, the pasted text stopped at the last character before thatCRchar.And guess what : I was able to reproduce this behavior even with the last
Win XPversion of Notepad++ which is the7.9.2release !
In other words, any text pasted in the
Find what:zone is not complete when you usually works withWindowsorMacfiles ! Is there any reason for this behavior ?Thanks, to all, for your investigations !
Best Regards,
guy038
P.S. :
However, note that if a text does not contain any
CRcharacter, you can paste, as expected, up to16,382characters in theFind what:zone, which may be searched later ! - 
@guy038 said in Wrong insertion of text, in the new FIND and REPLACE dialogs:
ONLY IF that text does not contain any CR character
This was the root cause in the recent How to replace two separate lines discussion.
Is there any reason for this behavior ?
- Reason that I know for certain: No.
 - Reason that I can guess: probably because Don’s original development was focused on single-line replacement, and wasn’t focused on multi-line search-and-replace; and since extended or regex modes allow 
\r\nfor multiline searches, being able to paste in a multi-line search (or replace) field probably never felt like a priority to Don. - Reason that is researchable: given the recent “replace two separate lines” discussion, I am quite certain there are more instances in this forum, if you can find the right search terms. And probably one or more open or closed Issues in the GitHub issue tracker. I would definitely do some detailed searching there, because it would very much surprise me if Don hadn’t weighed in on multi-line search/replace improvements before, so there’s probably a canonical answer somewhere in the ~17000 Issues; though good luck finding such a needle in a haystack.
 
 - 
Hello, @alan-kilborn, @peterjones and All,
Peter, I suppose that your second assumption should be the right one. I also verified this same behavior regarding the
Replace withzoneThus, until this behavior will be improved, the
Copy/Pasteoperations, within theFind/Replacedialog, works correctly forUnix-style files only !
However, I noticed that the
Incremental Searchis OK, regarding this problem :- 
Select any text with some line-endings, whatever they are
 - 
Open the
Incremental Searchpanel (Ctrl + Alt + I) 
=> All the multi-lines block is pasted in the Find zone
- 
Click on the
>button to find the next occurrence - 
If you select an other multi-lines block of text, simply redo a
Ctrl + Alt + Ioperation 
=> This new text should appear in the
Findzone- Click on  the 
>button to find the next occurrence 
And I pleased to note that, as expected, for the
v8.8.4release, you can paste up to16,382characters in the Find zone of theIncremental Searchpanel ! For older versions, you can paste till2,046charsBest Regards,
guy038
 - 
 - 
The Find/Replace/… dialog is using ComboBox controls for
Find whatandReplace with. A ComboBox is a single line control so once it reaches the CR then it truncates the string to that position and discards the rest. The type of control chosen limits the pasting of text by the user.Quote from ComboBox:
Is this the right control?
- Use a drop-down list to let users select a single value from a set of items that can be adequately represented with single lines of text.
 - Use a list or grid view instead of a combo box to display items that contain multiple lines of text …
 - …
 
A ComboBox has advantage of being a list though the disadvantage is that it is not designed for multiple lines of text.
The Incremental Search panel is using an Edit control for
Find. An Edit control is a multi-line control so it does not truncate at CR.This is why some editors use a large Edit control for their Find dialogs for pasting and viewing multiple lines of text. I am not suggesting changing controls or possible workarounds as that would need investigation and testing.
References:
- FindReplaceDlg.rc#L31 Resource line of 
Find whatusingCOMBOBOX - FindReplaceDlg.rc#L33 Resource line of 
Replace withusingCOMBOBOX - FindReplaceDlg.rc#L106 Resource line of incremental 
FindusingEDITTEXT 
 - 
Hi, @alan-kilborn, @peterjones, @mpheath and All,
Thanks, @mpheath, for your very informative post, relative to the
ComboBoxandEditTextcontrols !So, OK. I think you’re right about it. No need to change anything regarding the pasting behavior in the
Find/Replacedialogues, presently. We just have to remember to change current file into anUnixfile to have the opportunity to paste up to16,383characters, in theFindorReplacezones, when necessary.Of course, I will create, these next days, an official issue regarding the first bug, confirmed by @alan-kilborn, with a possible solution related in this post :
https://community.notepad-plus-plus.org/post/103072
If accepted, the work-around of using
Unix-stylefiles would even not be necessary !
Now, one advantage of increasing the search input length from
2,046to16,383is when using tokens. Indeed, you can now select any multi-lines text, up to16,383chars, whatever their line-endings status, and, after using one of the 5Style All Occurrences of Tokenoptions, it should highlight any identical block of text, found in the current file !
I’m also preparing an other post as I noticed that the number of bytes used, when using a
UTF-8text to be searched, differs, depending on whether :- 
You just select that text and open the
Finddialog - 
You copy that text, open and clear the
Finddialog, then paste that text in theFind whatzone 
Best Regards,
guy038
 - 
 - 
@guy038 said in Wrong insertion of text, in the new FIND and REPLACE dialogs:
No need to change anything regarding the pasting behavior in the Find/Replace dialogues, presently
I disagree, so I created issue 16952 and will submit a PR for it soon.
 - 
Hi, @alan-kilborn, @peterjones, @mpheath and All,
Alan, you said in your last post :
I disagree, so I created issue 16952 and will submit a PR for it soon.
Thank you for your involvement in finding a solution to this problem !
Now, I also created an issue regarding the
1,024bug : https://github.com/notepad-plus-plus/notepad-plus-plus/issues/16955Do you mind investigating in this issue, as well, as you already found out the root of this problem ?
Best Regards,
guy038
 - 
@guy038 said:
Do you mind investigating in this issue, as well, as you already found out the root of this problem ?
Yes, I will also look at that. I have special interest in that, because it is my code addition to Notepad++ that introduced the ability to set the threshold value (the field that you have set to
0). I wish I’d never done it; I started out with good intentions, but some others got involved and the feature went a little bit “wacky”. - 
Hello, @alan-kilborn and All,
Many thanks Alan to look into that issue, too. And, don’t be too upset about this side-effect of adding the threshold value. As we say in France, “you can’t make an omelet without breaking eggs” !
Now, I suppose that resolving the other issue
16952is a bit delicate : we’ll have to take care about :- 
The
extendedorregular expressionsearch mode which already allows syntaxes likeabc\r\ndef - 
The
regular expressionsearch mode which allows multi-lines syntax for a specific regex 
Therefore, I am more than willing to help and test your experimental version, if possible, in the hope of eliminating any potential problems : Notepad++'s
Search/Replace/Markfeature is very powerful. So let’s take the time necessary to ensure it stays that way !Best Regards,
guy038
 - 
 - 
@guy038 said:
I suppose that resolving the other issue 16952 is a bit delicate
I don’t see how the 2 points you made about it are of any concern to the fix I proposed.
Also, we may run into the problem that the Notepad++ author is not interested in the fix. - 
Hi @alan-kilborn and All,
After some tests, I just realized that it’s already the case ; So, there should not be any problem about it. Here is what I was thinking of :
Consider this simple text :
bla bla abcde fghij bla bla blah bla bla abcde fghij bla bla blah bla bla abcde fghij bla bla blah- 
Select the two complete lines
abcde+ CRLF +fghij+ CRLF - 
Open the Find dialog (
Ctrl+ F) - 
Check the
Wrap aroundoption - 
Choose the
Extended search mode 
=> You see, apparently the string
abcdefghijin the Find what: zone. But, indeed, it contains the real stringabcde\r\nfghij\r\n. So3occurrences of this string can be detected !But, if you wrongly think : “As I’m in extended mode, I should add the
\r\nat the end of each line for a correct search”, nothing will be detected !Of course, you could have found the same correct result, if, without any previous selection, you would have typed the string
abcde\r\nfghij\r\nin the Find what: zone, tooBest Regards,
guy038
 - 
 - 
@guy038 said:
After some tests
…of the version from the PR…
"…in extended mode, I should add the \r\n at the end of each line for a correct search”
Well… I think the answer to that is… don’t do it.
It’s a matter of knowing what your data is. And, admittedly, this is difficult as real
\rand\nare invisible in the Find what box. But this is true also if you select some multiline text and press Ctrl+f, it’s not peculiar to the proposed new code.