Skip to content

Commit

Permalink
fix bug in wrapinfo calculation with unicode text, Alexey-T/CudaText#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey-T committed Apr 16, 2023
1 parent cecd514 commit c984180
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
22 changes: 13 additions & 9 deletions atsynedit/atsynedit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2546,11 +2546,11 @@ procedure _CalcWrapInfos(
AFontProportional: boolean);
var
WrapItem: TATWrapItem;
WrapItemPtr: PATWrapItem;
NLineLen, NPartLen, NFoldFrom: integer;
NPartOffset, NIndent, NVisColumns: integer;
FinalState: TATWrapItemFinal;
bInitialItem: boolean;
StrPart: atString;
StrPart: UnicodeString;
begin
AItems.Clear;

Expand Down Expand Up @@ -2598,7 +2598,16 @@ procedure _CalcWrapInfos(
StrPart:= AStrings.LineSub(ALineIndex, NPartOffset, ATEditorOptions.MaxVisibleColumns)
else
StrPart:= AStrings.LineSub(ALineIndex, NPartOffset, NVisColumns);
if StrPart='' then Break;

if StrPart='' then
begin
if not bInitialItem then
begin
WrapItemPtr:= AItems._GetItemPtr(AItems.Count-1);
WrapItemPtr^.NFinal:= cWrapItemFinal;
end;
Break;
end;

NPartLen:= ATabHelper.FindWordWrapOffset(
ALineIndex,
Expand All @@ -2610,12 +2619,7 @@ procedure _CalcWrapInfos(
AWrapIndented
);

if NPartLen>=Length(StrPart) then
FinalState:= cWrapItemFinal
else
FinalState:= cWrapItemMiddle;

WrapItem.Init(ALineIndex, NPartOffset, NPartLen, NIndent, FinalState, bInitialItem);
WrapItem.Init(ALineIndex, NPartOffset, NPartLen, NIndent, cWrapItemMiddle, bInitialItem);
AItems.Add(WrapItem);
bInitialItem:= false;

Expand Down
1 change: 1 addition & 0 deletions atsynedit/atsynedit_wrapinfo.pas
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface
type
{ TATWrapItem }

PATWrapItem = ^TATWrapItem;
TATWrapItem = packed record
NLineIndex: integer;
NCharIndex: integer;
Expand Down

0 comments on commit c984180

Please sign in to comment.