duilio foschi wrote 16 lines
First of all, thanks for the patch.
Please only sent patches, the full files are not needed (and quickly outdated in case of trunk).
Ideally go to https://bugs.freepascal.org/ register and submit your patch with a new issue. I can not always deal with patches immediately, and in my mail inbox they can get lost very quickly. Once you opened an issue, you can link to it, when you sent an email.
Patches against trunk are the correct way.
Other than getting trunk, there is no need to deal with svn or any revision management system.
Besides the issues described below, your patch was very helpful, as it pointed me to the correct location for the fix. And it's review brought up more issues that need/needed fixing.
------------------------------------
About the patch itself.
Both of the issues below, had been present before your patch. So they are not a result of your patch.
I have fixed the first of the 2 issues, and committed this to trunk 2.1
***1)
If the text contains tabs, or special chars (such as umlauts äöü, accents, Japanese, Arabic, ....) then it can fail.
X (in the search code) is a byte position into the string. It is not a position on the screen.
https://wiki.lazarus.freepascal.org/SynEdit#Logical.2FPhysical_caret_position
Consider those Lines: . for spaces, \t shall be a tab, with tab-width = 4
........ab cd ef gh // 8 spaces "cd" is at x=12
ääääööööab cd ef gh // 8 umlauts (each 2 bytes) "cd" is at x=20 \t\tab cd ef gh // 2 tabs (same width as spaces) "cd" is at x=6 ........ab cd ef gh // 8 spaces "cd" is at x=12
However, the "cd" on each line are aligned on the screen. So you can have a column selection, that in each line has "cd ef g" If in that column selection you replace "ef" with "EF", then your ptStartX=12 and ptEndX=19 => will replace nothing in the 2 middle lines.
***2)
Further more, if the text to be replaced occurs twice on a line ........ab cd cd ef gh
and "cd" is replaced by "CB and more", then the 2nd "cd" may get pushed out of the range, before being replaced.
This is not yet fixed.
According to me test this is "compatible" with Delphi 10.3 (I.e. it seems to be not working in Delphi too)