Menu

#461 TSynCompletionProposal last item not shown

Not Fixed
open
nobody
None
7
2016-02-21
2016-02-19
Dennis07
No

I discovered a bug in the TSynCompletionProposal.
The bug caused the component to not show the last item in the list if selected.
I've already fixed it in my local unit. It affects the "TSynBaseCompletionProposalForm.Resize" procedure.
The current code is:

procedure TSynBaseCompletionProposalForm.Resize;
begin
inherited;
if FEffectiveItemHeight <> 0 then
FLinesInWindow := (Height - FHeightBuffer) div FEffectiveItemHeight;
if not(csCreating in ControlState) then
AdjustMetrics;
AdjustScrollBarPosition;
Invalidate;
end;

The corrected version has a "- 1" in the definition of "FLinesInWindow" because the counting begins with 0 and not with 1:

procedure TSynBaseCompletionProposalForm.Resize;
begin
inherited;
if FEffectiveItemHeight <> 0 then
FLinesInWindow := (Height - FHeightBuffer) div FEffectiveItemHeight - 1;
if not(csCreating in ControlState) then
AdjustMetrics;
AdjustScrollBarPosition;
Invalidate;
end;

Discussion

  • Dennis07

    Dennis07 - 2016-02-19

    ADDITION: The "TSynBaseCompletionProposalForm.CanResize" method also has the same bug.
    To fix it, just add the "- 1" there as well in line 1589 after the "(NewHeight-FHeightBuffer) div FEffectiveItemHeight". The new line then should look as follows:

    NewLinesInWindow := (NewHeight-FHeightBuffer) div FEffectiveItemHeight - 1;

     
  • Roman Kassebaum

    Roman Kassebaum - 2016-02-21

    I fixed the bug under GitHub: https://github.com/TurboPack/SynEdit.

     

Log in to post a comment.