Skip to content

Focus can be stranded on a hidden file tree (missing tree_hidden guards) #16

Closed

Description

@leboiko

Problem

Several key/mouse handlers set self.focus = Focus::Tree without checking tree_hidden. When the file tree is hidden (via Shift+H or the show_file_tree = false startup default added in #15), these paths land focus on a panel that isn't rendered, leaving the user on an invisible pane until they blindly press a key to escape.

These are pre-existing (already reachable via the H toggle before #15) — surfaced during the #15 review. Deferred from #15 to keep that PR scoped to the visibility setting.

Affected sites (as of b816f56)

  • src/app/key_handlers.rs — Tab in viewer (:357), last-tab close from viewer (:365), search-Esc (:675), copy-menu Enter/Esc (:727/:731)
  • src/app/mod.rs — ExitSearch action (~:898), mouse tab-close to empty (~:1113), FocusLeft action (~:845)

Proposed fix

Add a small helper and route all of these through it:

/// Focus the tree, or the viewer if the tree is hidden.
fn focus_tree_or_viewer(&mut self) {
    self.focus = if self.tree_hidden { Focus::Viewer } else { Focus::Tree };
}

Tests

Add focus-redirect tests for each entry point with tree_hidden = true asserting focus resolves to Focus::Viewer.

Scope

  • markdown-reader TUI

Activity

  1. added
    enhancement
    on Jun 11, 2026
  2. added a commit that references this issue on Jun 17, 2026
  3. leboiko commented on Jun 17, 2026

    @leboiko
    OwnerAuthor

    Fixed and shipped in v1.34.72 (via #20).

    The file-tree focus fixes are now in a released build — install/upgrade via Homebrew (brew upgrade markdown-reader), cargo install markdown-tui-explorer, the AUR markdown-reader-bin package, or the prebuilt binaries on the release page.

    Verified locally by the regression suite added with the fix (all green): watcher_rediscovery_preserves_user_tree_selection, tree_realigns_only_until_first_alignment, reveal_path_sets_aligned_only_on_a_real_match, and the per-entry-point *_respects_hidden_tree tests. Closing — please reopen if anything resurfaces.

  4. added a commit that references this issue on Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions