View Issue Details

IDProjectCategoryView StatusLast Update
0032667LazarusIDEpublic2018-12-18 21:15
ReporterBartek Dajewski Assigned ToJuha Manninen  
Status resolvedResolutionfixed 
Product Version1.6 
Summary0032667: [PATCH] SynEdit selects improper part of UTF8 text when Persistent Block option is active
TSynEdit component selects improper part of text if there are UTF8 characters before the caret. So does the IDE source editor. This behaviour depends on "Persistent block" option (or eoPersistentBlock in TSynEdit component).
The attached patch resolved this issue for me.
[OT] English is not my native language, so I apologize for any possible spelling and grammar mistakes.
Steps To ReproduceMake sure the "Persistent block" option is active (Tools/Options/Editor).

1. Place some text containing UTF8 characters in the editor window. Ex.:
   e=mc², A=πr², e^(πi)+1=0
2. Place the caret at the end of that line.
3. Press Shift+Left Arrow
   try to select last "0" with mouse.

Editor should select last character ("0"), but instead it selects three characters to the left of the caret ("+1="). Zero remains unselected.
Additional InformationAttached patch changes one line in TSynEditSelection.DoCaretChanged method:
   StartLineBytePos := FCaret.OldLineBytePos;
instead of previous:
   StartLineBytePos := Point(FCaret.OldCharPos, FCaret.OldLinePos);

Modified method is using only (...)BytePos coordinates without mixing them with (...)CharPos.
TagsNo tags attached.
Fixed in Revisionr56357
Attached Files


Bartek Dajewski

2017-11-09 00:54


TSynEditSelection.diff (591 bytes)   
Index: lazarus/components/synedit/syneditpointclasses.pas
--- lazarus/components/synedit/syneditpointclasses.pas	(wersja 56337)
+++ lazarus/components/synedit/syneditpointclasses.pas	(kopia robocza)
@@ -1736,7 +1736,7 @@
       FAltStartBytePos := -1;
     else begin
-      StartLineBytePos := Point(FCaret.OldCharPos, FCaret.OldLinePos);
+      StartLineBytePos := FCaret.OldLineBytePos;
       EndLineBytePos := FCaret.LineBytePos;
       if Persistent and IsBackwardSel then
TSynEditSelection.diff (591 bytes)   

Juha Manninen

2017-11-10 10:52

developer   ~0103991

I cannot reproduce with Lazarus trunk. I tested on Linux with GTK2 and QT bindings, and on Windows with Win32 bindings.
Please test again with trunk or Lazarus 1.8RCx.

Bartek Dajewski

2017-11-10 22:27

reporter   ~0103995

That's strange... I cannot not reproduce it ;-)
I've checked it once more from the very beginning. Describing step by step:
- I’ve downloaded
- make clean bigide
- lazarus.exe --pcp=MyTempConfDir
  (empty project started as usual)
- Then I’ve set "Persistent block" checkbox in Tools->Options->Editor.
- Finally I've pasted example text, i.e. "e=mc², A=πr², e^(πi)+1=0" into an empty line in the source editor window and pressed Shift+Left Arrow
That's all. Selected fragment is "+1="
Now tested on Windows 10 64bit, but before it was checked by me on the Win7/64 and WinXP/32 as well. Reproduced with lazarus 1.6.0, 1.6.2 binaries on all above Windows versions and with fresh compilation of 1.9.0 trunk (rev 56337).

Juha Manninen

2017-11-11 00:11

developer   ~0103996

Oops, it was poorly tested from my side. The bug is real and your patch actually helps. Applied, thanks.

Issue History

Date Modified Username Field Change
2017-11-09 00:54 Bartek Dajewski New Issue
2017-11-09 00:54 Bartek Dajewski File Added: TSynEditSelection.diff
2017-11-10 10:52 Juha Manninen LazTarget => -
2017-11-10 10:52 Juha Manninen Note Added: 0103991
2017-11-10 10:52 Juha Manninen Assigned To => Juha Manninen
2017-11-10 10:52 Juha Manninen Status new => feedback
2017-11-10 22:27 Bartek Dajewski Note Added: 0103995
2017-11-10 22:27 Bartek Dajewski Status feedback => assigned
2017-11-11 00:11 Juha Manninen Fixed in Revision => r56357
2017-11-11 00:11 Juha Manninen Note Added: 0103996
2017-11-11 00:11 Juha Manninen Status assigned => resolved
2017-11-11 00:11 Juha Manninen Resolution open => fixed