@@ -2601,6 +2601,8 @@ function M.open(opts)
26012601 local merged_config , base_path = initialize_picker (opts )
26022602 if not merged_config then return end
26032603
2604+ if base_path then M .change_indexing_directory (base_path ) end
2605+
26042606 -- Initialize grep_mode to first configured mode when opening in grep mode
26052607 if M .state .mode == ' grep' then
26062608 -- Use grep_config.modes if provided, otherwise fall back to global config
@@ -2616,6 +2618,34 @@ function M.open(opts)
26162618 return open_ui_with_state (query , nil , nil , merged_config , current_file_cache )
26172619end
26182620
2621+ --- Change the base directory for the file picker
2622+ --- @param new_path string New directory path to use as base
2623+ --- @return boolean ` true` if successful , ` false ` otherwise
2624+ function M .change_indexing_directory (new_path )
2625+ if not new_path or new_path == ' ' then
2626+ vim .notify (' Directory path is required' , vim .log .levels .ERROR )
2627+ return false
2628+ end
2629+
2630+ local expanded_path = vim .fn .expand (new_path )
2631+
2632+ if vim .fn .isdirectory (expanded_path ) ~= 1 then
2633+ vim .notify (' Directory does not exist: ' .. expanded_path , vim .log .levels .ERROR )
2634+ return false
2635+ end
2636+
2637+ local fuzzy = require (' fff.core' ).ensure_initialized ()
2638+ local ok , result = pcall (fuzzy .restart_index_in_path , expanded_path )
2639+ if not ok then
2640+ vim .notify (' Failed to change directory: ' .. result , vim .log .levels .ERROR )
2641+ return false
2642+ end
2643+
2644+ local config = require (' fff.conf' ).get ()
2645+ config .base_path = expanded_path
2646+ return true
2647+ end
2648+
26192649function M .monitor_scan_progress (iteration )
26202650 if not M .state .active then return end
26212651
0 commit comments