From f75c4cc3703d1f0f0aa11dbae3aecda49125dbe4 Mon Sep 17 00:00:00 2001 From: skalogryz Date: Tue, 2 Dec 2014 03:14:02 +0000 Subject: [PATCH] richmemo: mitigrate range operations git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3818 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/richmemo/richmemo.pas | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/richmemo/richmemo.pas b/components/richmemo/richmemo.pas index ef956ad1f..f950ee0b0 100644 --- a/components/richmemo/richmemo.pas +++ b/components/richmemo/richmemo.pas @@ -464,9 +464,9 @@ function TCustomRichMemo.GetContStyleLength(TextStart: Integer): Integer; var ofs, len : Integer; begin - if GetStyleRange(TextStart, ofs, len) then Result := len - (TextStart-ofs) - else Result := 1; - if Result = 0 then Result := 1; + if GetStyleRange(TextStart, ofs, len) + then Result := len - (TextStart-ofs) + else Result := 0; end; procedure TCustomRichMemo.SetSelText(const SelTextUTF8: string); @@ -550,7 +550,7 @@ begin end; l := GetContStyleLength(i); if i + l > j then l := j - i; - if l = 0 then l := 1; + if l = 0 then Break; SetTextAttributes(i, l, p); inc(i, l); end; @@ -563,7 +563,8 @@ var m : TParaMetric; begin repeat - GetParaRange(TextStart, TextStart, ln); + if not GetParaRange(TextStart, TextStart, ln) then Break; + if ln=0 then Break; GetParaMetric(TextStart, m); if pmm_FirstLine in ModifyMask then m.FirstLine:=ParaMetric.FirstLine;