[Lazarus] editor bug?

Martin Frb lazarus at mfriebe.de
Tue Mar 16 21:42:50 CET 2021


On 15/03/2021 19:01, duilio foschi via lazarus wrote:
>
> You will find a zip file at this link:
> https://mega.nz/file/T85iARDY#kK9i6JbM-aDJfRafL5PMN2MenSfxJoK4Yg9tnVwGsTo 
> <https://mega.nz/file/T85iARDY#kK9i6JbM-aDJfRafL5PMN2MenSfxJoK4Yg9tnVwGsTo>
>
> The zip file contains:
>
> 1. the corrected synedit.pp for Lazarus stable v. 2.0.12
> 2. the corrected synedit.pp for Lazarus trunk v. 2.1.0
> 3. the diff file for #1
> 4. the diff file for #2
>
> I am not accustomed to version control software.
>
> Please feel free to use the attached fix in the way you like
>
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)




More information about the lazarus mailing list