Well, that code is in another unit and can/is presumably called by multiple code paths.
What about this - I'm sure the error message text could be improved:
Index: components/synedit/synedit.pp
===================================================================
--- components/synedit/synedit.pp (revision 46622)
+++ components/synedit/synedit.pp (working copy)
@@ -881,7 +881,10 @@
property BlockBegin: TPoint read GetBlockBegin write SetBlockBegin; // Set Blockbegin. For none persistent also sets Blockend. Setting Caret may undo this and should be done before setting block
property BlockEnd: TPoint read GetBlockEnd write SetBlockEnd;
+ // The position of the first selected character in the control's text
+ // WARNING: Syn* SelStart IS 1 BASED while other edit controls ARE 0 BASED
property SelStart: Integer read GetSelStart write SetSelStart;
+ // WARNING: Syn* SelEnd IS 1 BASED
property SelEnd: Integer read GetSelEnd write SetSelEnd;
property SelAvail: Boolean read GetSelAvail;
property IsBackwardSel: Boolean read GetIsBackwardSel;
@@ -6960,6 +6963,8 @@
loop: integer;
count: integer;
begin
+ if Value<=0 then
+ raise Exception.CreateFmt('SelStart expected a value >= 1; received %d',[Value]);
loop := 0;
count := 0;
while (loop < FTheLinesView.Count) and (count + llen(FTheLinesView[loop]) < value) do begin
@@ -7018,6 +7023,8 @@
loop: integer;
count: integer;
begin
+ if Value<=0 then
+ raise Exception.CreateFmt('SelEnd expected a value >= 1; received %d',[Value]);
loop := 0;
count := 0;
while (loop < FTheLinesView.Count) and (count + llen(FTheLinesView[loop]) < value) do begin