Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revealing selection is broken for editors < 15 lines high #6673

Closed
tsmaeder opened this issue Oct 11, 2017 · 1 comment
Closed

Revealing selection is broken for editors < 15 lines high #6673

tsmaeder opened this issue Oct 11, 2017 · 1 comment
Labels
kind/bug Outline of a bug - must adhere to the bug report template. severity/P2 Has a minor but important impact to the usage or development of the system.

Comments

@tsmaeder
Copy link
Contributor

To reproduce:

  1. Open a Java class that is more than 15 lines long
  2. Add "System.out.println()" some place after the 15th line
  3. Do a "Find Usages" (Alt-F7)
  4. Resize the editor to 10 lines high
  5. In the usages view, double click the occurrence you have created in step Package docker runner in Che #2
  6. Observe: there is no selection visible in the editor.

The same thing works when the editor is > 15 lines high.

@tsmaeder
Copy link
Contributor Author

The problem is in OrionDocument.java:

  public void setSelectedRange(LinearRange range, boolean show) {
    int startOffset = range.getStartOffset();
    editorOverlay.setSelection(startOffset, startOffset + range.getLength(), show);

    TextPosition position = getPositionFromIndex(startOffset);
    if (show && position != null) {
      int lineNumber = position.getLine();
      int topIndex = lineNumber - MARGIN_TOP;
      editorOverlay.getTextView().setTopIndex(topIndex > 0 ? topIndex : 0);
    }
  }

This will always set the top index to 15 less than the selection line, which is bogus if the editor is less than 15 lines high.
I would suggest two improvements:

  1. Don't scroll if the selection is already visible. This makes the editor position jump less.
  2. if less than 30 lines are available, we should put the selection in the middle of the editor. In this way, we maximize the context we show before and after the line in question.

One other thing I noticed is that on one hand, we pass the "show" flag on to the editor overlay, on the other hand, we're setting the top position by hand. If we want to control the editor position, shouldn't we alsways pass "false" the the editor overlay?

@tsmaeder tsmaeder added the kind/bug Outline of a bug - must adhere to the bug report template. label Oct 11, 2017
@artaleks9 artaleks9 added the severity/P2 Has a minor but important impact to the usage or development of the system. label May 7, 2018
@vzhukovs vzhukovs added the ide6 label Mar 21, 2019
@tsmaeder tsmaeder closed this as completed Apr 2, 2019
@slemeur slemeur added target/che6 and removed ide6 labels Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Outline of a bug - must adhere to the bug report template. severity/P2 Has a minor but important impact to the usage or development of the system.
Projects
None yet
Development

No branches or pull requests

4 participants