Repository navigation
fix(explorer): allow file navigation before a hidden explorer is first shown - #568
Open
MarcusGasberg wants to merge 1 commit into
Open
MarcusGasberg wants to merge 1 commit into
MarcusGasberg wants to merge 1 commit into
Conversation
…t shown With explorer.hidden = true, the explorer split is hidden right after it is mounted, which clears its winid. navigate_next/navigate_prev passed that nil straight to nvim_win_is_valid, so next_file/prev_file threw "Invalid 'win': Expected Lua number" until the panel had been shown once. Guard the tree-cursor sync the same way toggle_staged_view and render.create already do, and cover it with an E2E case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
With
explorer = { hidden = true },next_file/prev_file(]f/[f) throw until the explorer has been toggled open at least once:render.createhides the split right after mounting it, andSplit:hide()clearssplit.winid, soexplorer.winidstarts outnil.navigate_next/navigate_prevpass it straight tonvim_win_is_valid, which rejectsnil. After the first togglewinidholds a window id (valid or stale), which is why the error only appears before the panel has ever been shown.Changes
lua/codediff/ui/explorer/actions.lua: guard the tree-cursor sync innavigate_nextandnavigate_prevwithexplorer.winid and ..., the same checktoggle_staged_viewandrender.createalready use.tests/e2e/explorer/actions_spec.lua: add[E21], which setsexplorer.hidden = true, then drivesnext_fileandprev_filefrom the diff pane and checks the comparison changes each time.Benefits
explorer.hidden = trueis usable with keyboard file navigation from the moment a session opens, instead of requiring a show/hide of the panel first.Testing
./tests/run_tests.sh tests/e2e/explorer/actions_spec.lua: 84 passed, 0 failed (E21 passes for native/polling × side-by-side/inline). Without the fix, E21 never completes: the mapping error leaves the embedded Neovim at a hit-enter prompt and the spec hits the 300s per-spec timeout../tests/run_tests.sh(full suite, Linux, Neovim 0.12.5): 1587 passed, 18 failed. All 18 failures are intests/integration/ui/conflict/gutter_grid_spec.lua(screen-grid glyph assertions, e.g. expected│ ╱╱╱╱, actual╰─╱╱╱╱), and that spec fails identically on unmodifiedmainin this environment, so it's unrelated to this change.stylua --checkclean on both files.🤖 Generated with Claude Code