8000 search: the detail pane never scrolls, because wrap_lines disables get_vertical_scroll · Issue #309 · nixidae/nixidae · GitHub
[go: up one dir, main page]

Skip to content

search: the detail pane never scrolls, because wrap_lines disables get_vertical_scroll #309

Closed

Description

@Lillecarl

What happens

alt+up and alt+down change SearchTui.detail_scroll, and the detail
pane on the screen does not move. Observed on a real terminal, 160x45,
against nixosConfigurations.hetztop: twelve alt+down presses on
nixpkgs.pkgs left the pane on the same first line.

Why

_build_detail_window builds the window with both of these:

wrap_lines=True,
get_vertical_scroll=lambda _window: self.detail_scroll,

prompt_toolkit's Window._scroll dispatches on wrap_lines:

  • _scroll_without_linewrapping reads get_vertical_scroll;
  • _scroll_when_linewrapping does not read it at all.

So the hook is dead code, and the only thing that moves the pane is
prompt_toolkit keeping the cursor visible. The cursor of that window
never moves.

Since when

Since b2b4edcd, the commit that added the interface. Both lines have
been there from the start.

Why it matters more now

Issue #305 draws default and example under the description. An
option with a long description therefore hides its own default, and no
key reaches it. nixpkgs.pkgs is the example: 18 lines of description
in a pane of 20 rows.

The tests do not catch it

test_alt_arrow_scrolls_the_detail_pane asserts tui.detail_scroll == 2.
That is the state variable, and the state variable was never the problem.
A test that catches this has to read what the window drew.

Two ways to fix it

  1. Move the cursor of the detail window, and let the scroll offsets
    put it at the top.
    _scroll_when_linewrapping clamps
    vertical_scroll to at most the cursor line, and clamps it from
    below by height - scroll_offsets.bottom. A bottom offset of
    height - 1 makes both bounds the cursor line exactly, so the
    cursor line becomes the top line. ScrollOffsets takes a callable,
    so the offset can read the measured window height.

  2. Wrap the text here, and set wrap_lines=False. get_vertical_scroll
    then works as written, and the arithmetic is ours. The Markdown
    renderer and package_tui already wrap to the width; a declaration
    path and a printed default value do not, so this needs a
    width-aware pass over StyleAndTextTuples that keeps the styles.

Acceptance

  • alt+down moves what the window draws, and not only the state.
  • A test reads the drawn window rather than detail_scroll.
  • The last line of a long detail is reachable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    source: nanopynix

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0