@Alan-Kilborn said in Bug when a multi-lines regex is used in the 'Search', 'Replace' or 'Mark' dialog:
It isn’t really a bug, it’s more of a historical vestige. Before the setting existed, 1024 was used for even more purposes. Think of the setting as always-existing, but at an unchangeable value: 1024.
Agreed but it’s not quite that bad at present. There is a constant within the npp source code that defines both the maximum value and default value for the Settings / Preferences / Searching / Minimum Size for Auto-Checking "In selection". It defaults to 1024. The length of the current selection is visible in the Sel: part of Notepad++'s status line. If the number is 0 to 1,023 and you do Ctrl+F, Ctrl+H, or Ctrl+M to bring up the Find, Replace, or Mark dialog boxes then the In Selection field will not be enabled. If the number is 1024 or larger and you do Ctrl+F, Ctrl+H, or Ctrl+M then In Selection field will be enabled. You can change this threshold via Settings / Preferences.
That works well.
The same internal constant that defines the default and/or maximum value for the Minimum Size for Auto-Checking "In selection" thing I just mentioned is also used by the code for the Find, Replace, and Mark dialog boxes to decide if the current selection should auto-populate the Find what field. If the current selection is from 1 to 1024 characters then Find what gets populated with whatever is in the selection. If the current selection is zero or is more than 1024 characters then the selection is ignored and Find what contains whatever was in there before.
The preferences setting for Minimum Size for Auto-Checking "In selection" does not control the current selection auto-populates Find what thing. Auto-population is a constant and is 1024.
A few weeks ago I wrote up some notes to myself about the name of this internal constant and started teasing out how and where the constant gets used. I can’t find my notes at the moment. My plan at the time was to submit a feature request on github that adds a new constant and showed exactly how and where in the code it should be used so that we can separate out the current selection to In selection vs current selection to Find what. I’d still like to do that but at the time I realized the npp code is a marvelously tangled ball of yarn and so needed to move carefully with my nip-n-tuck.
I also realized I probably should work on being able to compile my own copies if Notepad++.exe as there were areas where the current values of some internal variables are not obvious. I wanted to change the current selection to Find what limit from 1024 to 2047 characters and to do that should also fix whatever causes Notepad++'s 2046 character limit. Nearly all of Notepad++'s code thinks the limit for search patterns is 2047 characters but something in there restricts searches to 2046 characters.