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

View File

@ -589,6 +589,7 @@ begin
SynEdit.Options := [eoScrollPastEol]; SynEdit.Options := [eoScrollPastEol];
TestLeftRight('at EOL right', 5, 10, ecRight, 11, 9, 12,10); 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); TestLeftRight('at Max-left right', 5,199, ecRight, 200,198, 200,198, False, False);