Repository navigation
fix(open_file): select in the preview window when preview is true - #375
Conversation
With `preview: true`, openFile runs `:pedit`, which shows the file in the preview window and leaves the cursor in the main window. The selection, the text search, the focus and the makeFrontmost=false details all use the main window, which still shows another file. The unit spec mocks `:pedit` the way Neovim runs it, and the real-Neovim spec checks the selected text. Both fail until the next commit. _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
`:pedit` shows the file in the preview window and leaves the cursor in the window it ran in. openFile kept using that window, so it selected lines in the main window's file, searched startText there, focused it for makeFrontmost, and described its buffer in the makeFrontmost=false answer. openFile now looks up the preview window after `:pedit` and uses it for all four. makeFrontmost focuses it, as the VS Code extension focuses the editor it selects in. A missing preview window raises -32000. _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
|
@codex review |
|
@codex security review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
…in again Main changed selection.lua, utils.lua, openFile (#375), and the server's send path (#378, which makes each outbound message valid UTF-8). None of them changes a diff's status, which diffs close, or how many answers a call gets. check.sh passes on the merged tree. Part of #363 _Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
Why
This PR is one of the small, reviewed fixes that close the open follow-up issues in claudecode.nvim. With
preview: true,openFileruns:pedit, which shows the file in the preview window and keeps the cursor in the main window. openFile then selected in the main window's file. Lines 2 to 3 selectedtwo/threeofother.txt, notbeta/gammaof the previewedhello.txt. AstartTextsearch looked in the wrong file too, and themakeFrontmost: falseanswer reported the wrong file'slineCountandlanguageId.openFile now uses the preview window after
:pedit.makeFrontmostfocuses it, because Visual mode exists only in the current window. The VS Code extension also selects in the editor it opens, with or without preview.What changed
openFilefinds the preview window in the tab page where:peditran. It uses that window for the selection, the cursor, the focus, and the JSON details. It raises-32000when no preview window exists after:pedit.:peditthe way Neovim runs it, and a real-Neovim spec checks the selected text.lua/claudecode/tools/README.mddescribes the behavior.Scope
preview: truewith line ranges, text ranges,makeFrontmost: false, and a pending operator.:editpath does not change. The other items of the issue get their own PRs.Blast Radius
Only
openFilecalls withpreview: truechange. WithmakeFrontmosttrue (the default), the focus now goes to the preview window. Before, it went to the main window, which did not show the file.Verification
'selection'inclusive and exclusive, four layouts (one window, focus in a side window, no editor window, editor in another tab page). Before, every preview case selected in or searched the wrong file. After, every case selectsbeta/gammain the preview window, and no buffer text changes. A pendingdis cancelled and the nextwonly moves the cursor. With'selectmode'set tocmd, Select mode starts in the preview window and nothing is typed over it. Both versions give the same results.getCurrentSelectionandselection_changedreportbeta\ngammafromhello.txt.mise run check,mise run test(833 passed), and the integration suite on 0.8.3 and 0.12.3 (21 passed each) pass.Before the fix, the selection is in
other.txt:After the fix, the selection is in the preview window:
Part of #374
Generated with
xum• Model:anthropic:claude-opus-5-5• Thinking:xhigh