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

Unintended / incomprehensible auto-enable/-disable of scroll lock in TextConsoleViewer #669

Open
HeikoKlare opened this issue Sep 8, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@HeikoKlare
Copy link
Contributor

Current Behavior

In a TextConsoleViewer, as used by the Console view, scroll lock is automatically enabled or disabled under certain conditions. The basic idea seems to be that scroll lock is automatically disabled when navigating to the end of the view. But when pressing down/page-down, when scrolling, or when moving the scroll bar, scroll lock is even disabled if the navigation does not reach the end of the viewer (see also #649 (comment)). More precisely, it is disabled when after navigation the last shown line is less than X lines away from the last line of the viewer, where X is the line height in pixels. This is obviously unintended (comparing pixels with lines) and is particularly a result of a faulty implementation of checkEndDocument. However, it is not completely clear what the expected behavior would be.

More technically:

private boolean checkEndOfDocument() {
StyledText textWidget = getTextWidget();
if (textWidget != null && !textWidget.isDisposed()) {
int partialBottomIndex = JFaceTextUtil.getPartialBottomIndex(textWidget);
int lineCount = textWidget.getLineCount();
int delta = textWidget.getVerticalBar().getIncrement();
return lineCount - partialBottomIndex < delta;
}
return false;
}

The implementation compares line values (partialBottomIndex, lineCount) with pixels (the scroll bar increment delta), which obviously does not give correct results. The method checkStartDocument is equally faulty, but simply results in always returning false.

Expected Behavior

It is not completely clear what the currently intended behavior is. But it looks to me as if scroll lock should be disabled in case scrolling reaches the end of the view or if the end is already reached and some down-navigation key is pressed. And it should enable scroll lock whenever some up-navigation is performed if the topmost line has not already been reached.

Options

I see different options for the expected behavior under certain conditions.

When to do nothing:

  1. (Current) When the view contains less lines than can be display (i.e. when no scrollbar exists).
  2. (Probably current intention) Pressing some up-navigation key while the first line is visible.
  3. When pressing some up-navigation key while the cursor is in the first line.

When to disable scroll lock:

  1. (Probably current intention) As soon as the view is scrolled to the end.
  2. (Probably current intention) When pressing some down-navigation key while the last line is shown.
  3. When pressing some down-navigation key while the cursor is in the last line.
  4. (Current) When moving to the document end via CTRL+END.
  5. As soon as the cursor reaches the end of the contents.

When to enable scroll lock:

  1. (Probably current intention) Whenever an up-navigation is performed and the first line is not visible.
  2. (Current) When moving to the line start via HOME.
  3. Whenever an up-navigation is performed while the cursor is not in the first line.
  4. Whenever any up/down navigation is performed (key press or dragging the scroll bar) and the navigation did not move the cursor to the end of the contents.
  5. Whenever any navigation (including left/right) is performed (key press or dragging the scroll bar) and the navigation did not move the cursor to the end of the contents.

Proposed Option

I propose the following target behavior:

  • Nothing is done when pressing some up-navigation key while the cursor is in the first line
  • Scroll lock is disabled when:
    • the view is scrolled to the end
    • the cursor is in the last line and some down-navigation is performed
    • CTRL+END is used
  • Scroll lock is enabled when:
    • the view is scrolled and is not at the end
    • any vertical navigation is performed other than the ones disabling scroll lock

In particular, I would propose to always enable scroll lock when navigating vertically and not only when pressing some up-navigation key. When I start to navigate within in a console viewer (even using the down button), I usually want to do something at that very position and don't want to have the console keep scrolling.

Opinions

What opinions do you have with respect to the expected behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant