FIX: Viewer - Incorrect selection offset after search in Text mode (issue #1755)

(cherry picked from commit 1ee7a6b2b8)
This commit is contained in:
Alexander Koblov 2024-08-12 21:31:51 +03:00
commit edc41b641c

View file

@ -2827,7 +2827,7 @@ var
Inc(len); // Assume there is one character after conversion
// (otherwise use Inc(len, UTF8Length(s))).
if len <= FHPosition then
if (Mode = vcmText) and (len <= FHPosition) then
begin
i := i + CharLenInBytes;
Continue;
@ -3414,11 +3414,14 @@ begin
Update;
if (FVisibleOffset < FHPosition) or
(FVisibleOffset > FHPosition + FTextWidth) then
if FViewerControlMode = vcmText then
begin
SetHPosition(FVisibleOffset);
HScroll(-1);
if (FVisibleOffset < FHPosition) or
(FVisibleOffset > FHPosition + FTextWidth) then
begin
SetHPosition(FVisibleOffset);
HScroll(-1);
end;
end;
end;
end;