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

Fix tree reporter line highlighting #544

Merged

Commits on Feb 8, 2024

  1. tree: Fix highlighting for low numbered lines

    There were two different problems here:
    
    - When fetching lines from the file, we could choose a negative start
      index for the first line to display from the list of lines, resulting
      in no lines being shown.
    - When highlighting a line close to the start of the file, we failed to
      offset the highlighted line by the number of context lines we would
      have shown but couldn't because we ran out of lines.
    
    Signed-off-by: Matt Wozniski <[email protected]>
    godlygeek committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    196ade2 View commit details
    Browse the repository at this point in the history
  2. tree: Don't call linecache for the root node

    After fixing the bug where an empty list would be returned if there were
    not enough lines before the cursor line in the file, another bug was
    revealed by the test suite: we've been calling `linecache.getlines()`
    even for the root node. That's only noticeable in the test suite because
    we mock the return value from that function. In a real run of the
    tree reporter, we call `linecache.getlines()` with an empty string as
    the file name, and it always returns an empty list in that case.
    
    Still, better to fix this to recognize the root node and not attempt to
    fetch lines for it at all.
    
    Signed-off-by: Matt Wozniski <[email protected]>
    godlygeek committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    0cf12ab View commit details
    Browse the repository at this point in the history
  3. tests: Update tree reporter snapshots

    This accounts for both the two bugs fixed in the previous two commits,
    as well as a change in Textual 0.49: the cursor is no longer shown for
    unfocusable `TextArea` widgets.
    
    Signed-off-by: Matt Wozniski <[email protected]>
    godlygeek committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    d6f05d1 View commit details
    Browse the repository at this point in the history
  4. tests: Skip some more snapshot tests on Python 3.7

    The latest versions of Textual only support Python 3.8 and higher, so
    differences from the snapshot are expected when running Python 3.7.
    
    Signed-off-by: Matt Wozniski <[email protected]>
    godlygeek committed Feb 8, 2024
    Configuration menu
    Copy the full SHA
    fec7d8c View commit details
    Browse the repository at this point in the history