Skip to content

fix(explorer): preserve focus when auto-opening untracked files - #566

Open
emrearmagan wants to merge 2 commits into
esmuellert:mainfrom
emrearmagan:fix/preserve-explorer-focus
Open

emrearmagan wants to merge 2 commits into
esmuellert:mainfrom
emrearmagan:fix/preserve-explorer-focus

Conversation

@emrearmagan

Copy link
Copy Markdown

Summary

Keep the Explorer focused when auto-opening an untracked file in inline layout.

Problem

With auto_open_on_cursor = true, moving onto an untracked file with j/k opens the file but also moves focus from the Explorer to the diff pane.

This happens when the file's buffer has not been loaded yet. open_real_file() switches to the diff window to run :edit, but does not switch back afterward.

Fix

Use vim.api.nvim_win_call() to run :edit in the diff window without changing the user's current window.

Testing

  • ./tests/run_tests.sh tests/integration/ui/explorer/creation_spec.lua — 18 passed, 0 failed
  • stylua --check lua/codediff/ui/view/helpers.lua
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant