Qt5: fixed behaviour of TMemo.Lines.Add(), still slower than gtk or win32, but have correct behaviour when last line of memo is line break. For faster inserts remove last line break. issue #39444

This commit is contained in:
Željan Rikalo 2022-11-13 18:13:09 +01:00
parent 38f4119540
commit 6a197ad3ca

View File

@ -437,11 +437,22 @@ begin
// simplified because of issue #29670
// allow insert invalid index like others do
if Index >= FStringList.Count then
Index := FStringList.Add(S)
else
begin
Index := FStringList.Add(S);
if FHasTrailingLineBreak then
W := GetUTF8String(S + LineBreak)
else
W := GetUTF8String(S);
if FHasTrailingLineBreak then
TQtTextEdit(FOwner.Handle).setLineText(Index, W)
else
TQtTextEdit(FOwner.Handle).Append(W);
end else
begin
FStringList.Insert(Index, S);
W := GetUTF8String(S);
TQtTextEdit(FOwner.Handle).insertLine(Index, W);
W := GetUTF8String(S);
TQtTextEdit(FOwner.Handle).insertLine(Index, W);
end;
FTextChanged := False; // FStringList is already updated, no need to update from WS.
end;