SynEdit: fixes for exact scroll range depending on "caret past eol" options. Ensure setting new options takes immediate effect

This commit is contained in:
Martin 2023-06-02 16:36:16 +02:00
parent a236413e40
commit 3ea6f9923c
2 changed files with 19 additions and 8 deletions

View File

@ -4819,18 +4819,18 @@ begin
if not HandleAllocated then // don't know chars in window yet
exit(MaxInt);
Result := FTheLinesView.LengthOfLongestLine;
Result := FTheLinesView.LengthOfLongestLine + 1;
if (eoScrollPastEolAddPage in Options2) then
Result := Result + CharsInWindow - 1;
Result := Result + CharsInWindow - 1 - FScreenCaret.ExtraLineChars;
if (eoScrollPastEol in Options) and (Result < fMaxLeftChar) then
Result := fMaxLeftChar;
if (eoScrollPastEolAutoCaret in Options2) and (Result < FCaret.CharPos) then
Result := FCaret.CharPos;
if AIncludeCharsInWin then
Result := Result + 1 + FScreenCaret.ExtraLineChars
Result := Result + FScreenCaret.ExtraLineChars
else
Result := Result - CharsInWindow + 1 + FScreenCaret.ExtraLineChars;
Result := Result - CharsInWindow + FScreenCaret.ExtraLineChars;
if Result < 1 then Result := 1;
end;
@ -4844,9 +4844,9 @@ begin
Result := FTheLinesView.LengthOfLongestLine + 1;
if (eoScrollPastEolAddPage in Options2) then
Result := Result + CharsInWindow - 1;
Result := Result + CharsInWindow - 1 - FScreenCaret.ExtraLineChars;
if (eoScrollPastEol in Options) and (Result < fMaxLeftChar + 1) then
Result := fMaxLeftChar + 1;
Result := fMaxLeftChar;
if Result < 1 then Result := 1;
end;
@ -8416,9 +8416,13 @@ begin
FOptions := Value;
UpdateOptions;
if not (eoScrollPastEol in Options) then
if eoScrollPastEol in ChangedOptions then begin
Include(fStateFlags, sfScrollbarChanged);
LeftChar := LeftChar;
if (eoScrollPastEol in Options) or (eoScrollPastEof in Options) then begin
if sfScrollbarChanged in fStateFlags then
UpdateScrollbars;
end;
if (eoScrollPastEof in ChangedOptions) then begin
UpdateScrollBars;
TopView := TopView;
end;
@ -8488,6 +8492,12 @@ begin
UpdateCursor;
if (eoPersistentCaretStopBlink in ChangedOptions) then
UpdateScreenCaret;
if ChangedOptions * [eoScrollPastEolAddPage, eoScrollPastEolAutoCaret] <> [] then begin
Include(fStateFlags, sfScrollbarChanged);
LeftChar := LeftChar;
if sfScrollbarChanged in fStateFlags then
UpdateScrollbars;
end;
StatusChanged([scOptions]);
end;
end;

View File

@ -589,6 +589,7 @@ begin
SynEdit.Options := [eoScrollPastEol];
TestLeftRight('at EOL right', 5, 10, ecRight, 11, 9, 12,10);
TestLeftRight('after EOL right', 5, 99, ecRight, 100, 98, 101, 99, False, False);
TestLeftRight('at Max-left right', 5,199, ecRight, 200,198, 200,198, False, False);