Repository navigation
fix(nvim): don't require the picker UI for file_search/content_search with cwd - #966
Conversation
… with cwd ensure_indexed waits through file_picker.wait_for_initial_scan, which returns false until file_picker.setup() has run. Only the picker UI calls setup(), so API-only callers that pass a different cwd got "timeout waiting for index scan". Call setup() from ensure_indexed when it has not run yet. Refs dmtrKovalenko#938
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Initialize the picker for programmatic searches lua/fff/main.lua, tests/programmatic_search_spec.lua |
ensure_indexed sets up the file picker when it is uninitialized and uses the loaded module to wait for the initial scan. Tests check sandbox search results and error notifications when picker UI setup is disabled. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: dmtrkovalenko
Merge Risk: 
Minimal · up to fb97e
-
No concrete merge-blocking risk is established by the reviewed evidence.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed -
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
…r-UI case Follow the cwd switching block: skip the delete when before_each did not create the sandbox, nil it afterwards, and wait 250 ms on Windows after writing grep_target.lua.
Refs #938
This is the "separate, smaller issue" from #938. The watcher hang itself is handled in #939; this PR doesn't touch it.
Problem
file_searchandcontent_searchwith acwdthat differs from the current root fail at once withtimeout waiting for index scanand return nothing, unlessrequire('fff.file_picker').setup()was called first.ensure_indexed(lua/fff/main.lua) callscore.ensure_initialized(), switches the root, then waits onfile_picker.wait_for_initial_scan. That returnsfalsewhilefile_picker.state.initializedis unset, and onlyfile_picker.setup()sets it.setup()is only called from the picker UI (picker_ui.lua:126,626), so a caller that only uses the programmatic API never gets past the wait. The existing specs callsetup()inbefore_each, which is why they didn't catch it.Reproduction
From a checkout of
main(7353971),nvim --headless -u NONE -i NONE -l repro.lua:Before:
FFF file_search: timeout waiting for index scan, then0. After:100.Fix
ensure_indexedcallsfile_picker.setup()right aftercore.ensure_initialized()if it hasn't run yet, the same check the picker UI does before opening.setup()only sets the Lua-side flag andbase_path, so nothing changes for callers that open the picker or already callsetup(). No public API change.I left
wait_for_initial_scanand the otherfile_pickerguards as they are. If you'd rather havecore.ensure_initialized()set the flag, I can move it there.Tests
New
cwd switching without the picker UIblock intests/programmatic_search_spec.lua. It savesfile_picker.state.initializedand sets it tofalseinbefore_each(restored inafter_each), then runsfile_searchandcontent_searchagainst a fresh sandboxcwdand checks that nothing is notified as an error and the sandbox file or match comes back. The notify check matters forcontent_search: polling for the match alone would pass without the fix.With
lua/fff/main.luareverted the spec gives 12 pass / 2 fail, bothtimeout waiting for index scan; with the fix, 14/14.Ran locally on macOS arm64, Neovim 0.12.6, with the prebuilt
aarch64-apple-darwin.dylibfrom the0.11.1-nightly.7353971release intarget/release/(I don't have cargo here, and this PR only changes Lua):PlenaryBustedDirectory tests/(whatmake test-luaruns): 71 pass, 0 failstylua --check .,luacheck lua/,lua-language-server --check=.: clean (thevim.notifystub needs aduplicate-set-fielddisable)programmatic_search_spec.luais flaky on macOS under load, both onmainand on this branch (3/30 runs each, every failure stuck ~50 s on a scan wait), which looks like the #938 hang that #939 fixes. On an otherwise idle machine, 50 more runs of this branch had no hangs.Not run: a Rust build, Neovim 0.10.4 (CI's version), Linux, Windows,
make test-lua-snap.