-
Notifications
You must be signed in to change notification settings - Fork 452
fix: rebuild file picker after FFFClearCache files (#772) #773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,7 +101,13 @@ function M.clear_cache(scope) | |
|
|
||
| if scope == 'all' or scope == 'files' then | ||
| local ok, err = pcall(fuzzy.cleanup_file_picker) | ||
| if not ok then table.insert(errors, 'cleanup file picker: ' .. tostring(err)) end | ||
| if not ok then | ||
| table.insert(errors, 'cleanup file picker: ' .. tostring(err)) | ||
| else | ||
| -- Rust picker is gone; clear the core flag so the next ensure_initialized | ||
| -- rebuilds it instead of operating on a dropped picker (#772). | ||
| require('fff.core').mark_file_picker_uninitialized() | ||
| end | ||
|
Comment on lines
102
to
+110
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Check established vim.validate() usage before selecting an API form.
ast-grep run --lang lua --pattern 'vim.validate($$$)' lua
# Find the repository's declared Neovim compatibility version.
rg -n -i -C2 'neovim|nvim|minimum.*version' \
-g 'README.md' -g '*.rockspec' -g '*.toml' -g '*.json' -g '*.yml' -g '*.yaml' .Repository: dmtrKovalenko/fff Length of output: 8162 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- clear_cache implementation ---'
sed -n '70,140p' lua/fff/main.lua
printf '%s\n' '--- callers and scope values ---'
rg -n -C3 'clear_cache|scope\s*=' lua tests spec 2>/dev/null || true
printf '%s\n' '--- vim.validate metadata and project version clues ---'
rg -n -C3 'function vim\.validate|vim\.validate\s*=|validate\s*=\s*function|minimum.*(nvim|neovim)|neovim.*version|nvim.*version|requires.*nvim' \
lua .github README.md Cargo.toml '*.rockspec' '*.toml' '*.json' '*.yml' '*.yaml' 2>/dev/null || trueRepository: dmtrKovalenko/fff Length of output: 6947 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- clear-cache tests ---'
cat -n tests/clear_cache_spec.lua
printf '%s\n' '--- public command and documentation callers ---'
rg -n -C4 'FFF.*Cache|clear_cache|clear cache|cache.*scope|scope.*frecency|scope.*files' . \
-g '!package-lock.json' -g '!*.svg'
printf '%s\n' '--- repository files that may declare compatibility ---'
git ls-files | rg -i '(^|/)(readme|changelog|changes|install|init|plugin|.*rockspec|.*toml|.*json|.*ya?ml)$|nvim|neovim'Repository: dmtrKovalenko/fff Length of output: 16086 🌐 Web query:
💡 Result: The vim.validate API in Neovim is a utility function used to check the types and values of function arguments [1][2]. As of Neovim 0.11 and later, the API has undergone significant changes regarding its supported syntax and deprecation status [3][4][5]. Syntax and Allowed Values: The API currently emphasizes a "fast form" which is highly optimized [3][6]. 1. Standard Usage (Fast Form): The recommended syntax is vim.validate(name, value, validator, optional, message) [2][7]. - name: A string representing the argument name [2]. - value: The actual value to be validated [2]. - validator: A string, a list of strings, or a function [2][7]. - String/List of strings: Must correspond to types returned by the Lua type function (e.g., 'string', 'number', 'table', 'boolean', 'nil', 'callable', 'function', 'thread', 'userdata') [2][7]. - Callable: A function that receives the value and returns a boolean (and optionally a string error message) [2][7]. - optional: A boolean indicating if the parameter can be nil [2][7]. - message: An optional custom error message [2]. 2. Deprecated Form (Spec Form): The older syntax, which accepted a single table as a specification (vim.validate({ spec })), has been deprecated starting in Neovim 0.11 and is slated for removal in Neovim 1.0 [3][4][5]. Developers are advised to migrate to individual calls using the fast form [5]. Version and Scope: - Introduced: vim.validate was introduced to standardize argument checking and reduce reliance on manual assert calls [1]. - Deprecation: The spec-based table syntax was deprecated in version 0.11 [3][5]. - Scope: It is intended for validating public API or function arguments where type safety is required [2][8]. Because the function incurs a small performance overhead compared to raw assertions, it is generally recommended to use standard Lua assert for performance-critical or internal/private functions [6][8]. Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- standalone Lua behavior probe ---'
if command -v lua >/dev/null 2>&1; then
lua - <<'LUA'
local function clear_cache_behavior(scope)
if not scope or scope == '' then scope = 'all' end
local file_cleanup = scope == 'all' or scope == 'files'
local db_cleanup = scope == 'all' or scope == 'frecency'
local ok, message = pcall(function()
return 'Cleared FFF cache: ' .. scope
end)
return scope, file_cleanup, db_cleanup, ok, message
end
for _, scope in ipairs({nil, '', 'all', 'files', 'frecency', 'bogus', false, {}}) do
local label = scope == nil and 'nil' or type(scope) .. ':' .. tostring(scope)
local normalized, files, frecency, ok, message = clear_cache_behavior(scope)
print(label, '=>', tostring(normalized), files, frecency, ok, message or '')
end
LUA
else
echo 'lua executable unavailable'
fi
printf '%s\n' '--- exact validation usage and command boundary ---'
sed -n '255,285p' lua/fff/main.lua
sed -n '55,72p' plugin/fff.luaRepository: dmtrKovalenko/fff Length of output: 2104 Validate Unknown strings skip every cleanup operation but return success. Use 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| end | ||
|
|
||
| if scope == 'all' or scope == 'frecency' then | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Stop scans when picker initialization fails.
At Line 200,
ensure_initializedreturnsfuzzyafter picker creation fails.lua/fff/main.luaLines 192-196 ignore that failure. A scan can then run with no Rust picker.Return an explicit failure result. Make
ensure_indexedstop before scan. Apply the same contract to the refusal branch at Lines 151-155.🤖 Prompt for AI Agents