mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-22 23:01:35 +02:00
Qt: fixed TQtMemoString.Insert() and TQtTextEdit.insertLine(). issue #29670
git-svn-id: trunk@51658 -
This commit is contained in:
parent
724c7e9cd6
commit
f9d4440db3
@ -418,51 +418,22 @@ end;
|
||||
procedure TQtMemoStrings.Insert(Index: integer; const S: string);
|
||||
var
|
||||
W: WideString;
|
||||
|
||||
function WorkaroundNeeded: Boolean;
|
||||
var
|
||||
HaveLt: Boolean;
|
||||
HaveGt: Boolean;
|
||||
begin
|
||||
HaveLt := System.Pos('<', S) > 0;
|
||||
HaveGt := System.Pos('>', S) > 0;
|
||||
Result := HaveLt or HaveGt;
|
||||
end;
|
||||
|
||||
begin
|
||||
if FTextChanged then InternalUpdate;
|
||||
if Index < 0 then Index := 0;
|
||||
|
||||
{$ifdef VerboseQtMemoStrings}
|
||||
writeln('TQtMemoStrings.Insert Index=',Index);
|
||||
writeln('TQtMemoStrings.Insert Index=',Index,' COUNT=',FStringList.Count);
|
||||
{$endif}
|
||||
|
||||
if Index <= FStringList.Count then
|
||||
begin
|
||||
// simplified because of issue #29670
|
||||
// allow insert invalid index like others do
|
||||
if Index >= FStringlist.Count then
|
||||
Index := FStringList.Add(S)
|
||||
else
|
||||
FStringList.Insert(Index, S);
|
||||
if (TQtTextEdit(FOwner.Handle).getBlockCount - Index <= 1) then
|
||||
begin
|
||||
// workaround for qt richtext parser bug. issues #17170 and #22715
|
||||
if WorkaroundNeeded then
|
||||
begin
|
||||
W := GetUTF8String(S);
|
||||
if (Index >= FStringList.Count - 1) then
|
||||
TQtTextEdit(FOwner.Handle).appendLine(W)
|
||||
else
|
||||
TQtTextEdit(FOwner.Handle).insertLine(Index, W);
|
||||
end else
|
||||
begin
|
||||
// append is much faster in case when we add strings
|
||||
W := S;
|
||||
ExternalUpdate(W, False, False);
|
||||
FTextChanged := False;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
W := GetUTF8String(S);
|
||||
TQtTextEdit(FOwner.Handle).insertLine(Index, W);
|
||||
end;
|
||||
end;
|
||||
W := GetUTF8String(S);
|
||||
TQtTextEdit(FOwner.Handle).insertLine(Index, W);
|
||||
end;
|
||||
|
||||
procedure TQtMemoStrings.LoadFromFile(const FileName: string);
|
||||
|
@ -9544,7 +9544,8 @@ begin
|
||||
// QTextCursor slowness
|
||||
// https://bugreports.qt-project.org/browse/QTBUG-3554
|
||||
// differentiate append vs. insert issue #22715
|
||||
if AIndex >= FList.Count - 1 then
|
||||
// added check for AIndex. issue #29670
|
||||
if (AIndex > 0) and (AIndex >= FList.Count - 1) then
|
||||
begin
|
||||
QTextCursor_movePosition(QtCursor, QTextCursorEnd,
|
||||
QTextCursorMoveAnchor, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user