diff --git a/components/synedit/synedit.pp b/components/synedit/synedit.pp index 3130d77cad..7c79d833f4 100644 --- a/components/synedit/synedit.pp +++ b/components/synedit/synedit.pp @@ -3267,9 +3267,9 @@ var procedure ExpandSpecialChars(var p: PChar; var Count: integer; PhysicalStartPos: integer); - // if there are no tabs: keep p and Count untouched - // if there are tabs: copy p into ExpandedPaintToken buffer, - // convert tabs to spaces, and return the buffer + // if there are no tabs or special chars: keep p and Count untouched + // if there are special chars: copy p into ExpandedPaintToken buffer, + // convert tabs to spaces, and return the buffer var i: integer; TabCount, LengthNeeded: Integer; @@ -3284,8 +3284,10 @@ var TabCount:=0; for i:=0 to Count-1 do if p[i]=#9 then inc(TabCount); - if TabCount=0 then exit; - LengthNeeded:=Count+TabCount*8; + if (TabCount=0) + and (FindInvalidUTF8Character(p,Count)<0) then + exit; + LengthNeeded:=Count+TabCount*TabWidth; if length(ExpandedPaintToken)