How can I get Eclipse to scroll past the bottom of the document?

前端 未结 1 516
有刺的猬
有刺的猬 2020-12-08 13:16

When I scroll to the bottom of an open document in the Eclipse editor, the last line is at the bottom of the file. This is a tad annoying

相关标签:
1条回答
  • 2020-12-08 13:32

    Considering the current implementation of a Scrollbar, this is not possible.
    (See org.eclipse.swt.widgets.ScrollBar.java)

    At any given moment, a given scroll bar will have a single 'selection' that is considered to be its value, which is constrained to be within the range of values the scroll bar represents (that is, between its minimum and maximum values).

    In the JDT (Java Editor) realm, the range is strongly linked to the number of lines a source file has.
    Adding artificial "logical lines" to allows scrolling past the last line would have unintended consequences on many other parts of the JDT, related to displaying informations based on the line number of a source file (like a compilation error red underline).

    This is also why there is no soft wrapping in those editors, despite a 7-years old bug 35779 (one of the most upvoted).

    Allowing word/soft wrap in the editor while typing is easy but not enough, a mapping between the model lines and the visual lines must be introduced to e.g. correctly show annotations.
    It also introduces various problems that need to be solved, e.g. 'Go to Line': tools like a debugger, compiler etc. will report the model line but a user it will look strange that a different line will be selected than the one entered into the 'Go to Line' dialog

    So for now, the SWT scrollbar example is still limited by the bottom of the window:

    http://www.java2s.com/Code/JavaImages/ScrollBarExample.PNG

    0 讨论(0)
提交回复
热议问题