View Issue Details

IDProjectCategoryView StatusLast Update
0020299LazarusLCLpublic2011-09-20 22:56
ReporterBart Broersma Assigned ToMartin Friebe  
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status closedResolutionfixed 
Product Version0.9.31 (SVN) 
Target Version1.2.0Fixed in Version0.9.31 (SVN) 
Summary0020299: SynEdit behaviour when ctrl-y deleting lines (feature) [SynEdit crashes when pressing Ctrl+Y on last line]
DescriptionWhen in a synedit, goto the last line.
Press Ctrl+Y (delete line).
The first two times this goes OK, but after the second time, the cursor stays below the last line, and pressing Ctrl+Y again crashes the app.

Only tested onWindows yet.
Steps To ReproduceRun attached sample program and do as described before.
Additional InformationStacktrace after the crash.
TApplication.HandleException Invalid stringlist index 95
  Stack trace:
  $00562750 line 447 of synedittextbuffer.pp
  $00563AB5 line 872 of synedittextbuffer.pp
  $00564309 line 1024 of synedittextbuffer.pp
  $00564950 line 1084 of synedittextbuffer.pp
  $0054D501 line 1047 of synedittexttrimmer.pas
  $00547B14 line 1065 of synedittextbase.pas
  $00547B14 line 1065 of synedittextbase.pas
  $0052E943 line 6403 of synedit.pp
  $0052D5E4 line 6118 of synedit.pp
  $00523A54 line 2434 of synedit.pp
  $004DB736 line 5485 of include/
  $004DB9B4 line 5654 of include/
  $004DDD19 line 6941 of include/
  $004DAED2 line 5243 of include/
  $0052C376 line 5711 of synedit.pp
  $0051B231 line 111 of lclmessageglue.pas
TagsNo tags attached.
Fixed in Revision32424
Attached Files


2011-09-19 19:54 (4,544 bytes)

2011-09-19 20:25


synedit.eclinedelete.diff (844 bytes)   
Index: components/synedit/synedit.pp
--- components/synedit/synedit.pp	(revision 32422)
+++ components/synedit/synedit.pp	(working copy)
@@ -6397,9 +6397,12 @@
         if not ReadOnly and not ((FTheLinesView.Count = 1) and (Length(FTheLinesView[0]) = 0))
         then begin
-          if FTheLinesView.Count = 1 then
+          if (FTheLinesView.Count = 1)  then
             FTheLinesView.EditDelete(1, 1, length(FTheLinesView[0]))
           else begin
+          if (FTheLinesView.Count = CaretY) then
+            FTheLinesView.EditDelete(1, CaretY, Length(FTheLinesView[CaretY-1]))
+          else
             FTheLinesView.EditLinesDelete(CaretY, 1);
           CaretXY := Point(1, CaretY); // like seen in the Delphi editor
synedit.eclinedelete.diff (844 bytes)   

Bart Broersma

2011-09-19 20:26

developer   ~0052040

Attached diff contains a "lame" patch.

Note: the IDE suffers from the same bug.

Martin Friebe

2011-09-19 20:43

manager   ~0052042

Please test and close if ok

Bart Broersma

2011-09-20 17:54

developer   ~0052064


First of all: the crash is fixed.

From an "enduser point of view" however, I tend to disagree with your solution.
Although it fixes the crash, it introduces IMO unexpected (and AFAIAC unwanted) new behaviour.

For me a typical scenario is deleting lines (normally jus a few) until the end of the synedit. (I simply press and hold Ctrl+Y)
What you see is that lines beginning at the current line, and then starting below are getting deleted.
Then, with your patch, all of the sudden (when eof is reached) it starts deleting lines above where my cursor was, which in moste cases is unwanted.

It is also not compatible with the way the Delpi editor works (and the comment in line 6408 suggest that it is supposed to mimick the Delpi editor behaviour)
(synedit.pp line 6408:
  CaretXY := Point(1, CaretY); // like seen in the Delphi editor

All this, of course, is a matter of opinion (or taste if you like).

If you do not share my point of view, then feel free to resolve (again) and also close the issue.

Martin Friebe

2011-09-20 18:43

manager   ~0052066

I have changed it to feature now. I may look for a solution, if/when time allows.

Naturally the issue was with the caret ending up, outside the text. That simple is not planed / allowed.

Problems with the caret beyond the end of code, are not limited to ctrl-y. Other actions would cause crashes too, if the caret leaves the defined scope

Rather than adding lots of code everywhere checking if the caret is in the defined range, I will probably change ctr-y

If you ctrl-y on the last line of code, then the line will be emptied, but not deleted => that way, once the line is empty no further action happens.

For a user this is the same, as you request. If the line was deleted, but the caret allowed, and you started typing, the line would be created.
The only difference is, when you save the file => you will get that empty line at the end.

Martin Friebe

2011-09-20 19:13

manager   ~0052067

Implemented in 32436

Bart Broersma

2011-09-20 22:56

developer   ~0052071

Works like a charm.
Thanks for honouring my request.

Issue History

Date Modified Username Field Change
2011-09-19 19:54 Bart Broersma New Issue
2011-09-19 19:54 Bart Broersma File Added:
2011-09-19 19:54 Bart Broersma LazTarget => -
2011-09-19 19:54 Bart Broersma Widgetset => Win32/Win64
2011-09-19 20:21 Martin Friebe Status new => assigned
2011-09-19 20:21 Martin Friebe Assigned To => Martin Friebe
2011-09-19 20:25 Bart Broersma File Added: synedit.eclinedelete.diff
2011-09-19 20:26 Bart Broersma Note Added: 0052040
2011-09-19 20:43 Martin Friebe Fixed in Revision => 32424
2011-09-19 20:43 Martin Friebe LazTarget - => 0.99.0
2011-09-19 20:43 Martin Friebe Widgetset Win32/Win64 =>
2011-09-19 20:43 Martin Friebe Status assigned => resolved
2011-09-19 20:43 Martin Friebe Fixed in Version => 0.9.31 (SVN)
2011-09-19 20:43 Martin Friebe Resolution open => fixed
2011-09-19 20:43 Martin Friebe Note Added: 0052042
2011-09-20 17:54 Bart Broersma Status resolved => assigned
2011-09-20 17:54 Bart Broersma Resolution fixed => reopened
2011-09-20 17:54 Bart Broersma Note Added: 0052064
2011-09-20 18:43 Martin Friebe Note Added: 0052066
2011-09-20 18:43 Martin Friebe Severity minor => feature
2011-09-20 18:43 Martin Friebe Target Version 0.99.0 => 1.2.0
2011-09-20 18:43 Martin Friebe Summary SynEdit crashes when pressing Ctrl+Y on last line => SynEdit behaviour when ctrl-y deleting lines (feature) [SynEdit crashes when pressing Ctrl+Y on last line]
2011-09-20 19:13 Martin Friebe Status assigned => resolved
2011-09-20 19:13 Martin Friebe Resolution reopened => fixed
2011-09-20 19:13 Martin Friebe Note Added: 0052067
2011-09-20 22:56 Bart Broersma Status resolved => closed
2011-09-20 22:56 Bart Broersma Note Added: 0052071