Skip to content

feat: Correctly handle change of cwd automatically and via API#27

Merged
dmtrKovalenko merged 1 commit into
mainfrom
feat/follow-cwd
Aug 2, 2025
Merged

feat: Correctly handle change of cwd automatically and via API#27
dmtrKovalenko merged 1 commit into
mainfrom
feat/follow-cwd

Conversation

@dmtrKovalenko
Copy link
Copy Markdown
Owner

closes #20

This allows to use

require('fff.main').find_files_in_dir('/Users/neogoose/dev/lightsource')

to change cwd and start the picker immediately to choose the file.

@dmtrKovalenko dmtrKovalenko requested a review from Copilot August 2, 2025 21:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality to handle changing the current working directory both automatically (via Neovim's DirChanged event) and programmatically through a new API. The changes allow users to reinitialize the file picker with a new directory without having to manually restart the plugin.

  • Adds automatic detection of directory changes and re-initializes the file picker accordingly
  • Introduces a new find_files_in_dir() API function for programmatic directory switching
  • Removes legacy debug code that was no longer needed

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
lua/fff/rust/lib.rs Adds restart_index_in_path function to reinitialize file picker with new directory
lua/fff/main.lua Adds autocmd for DirChanged events and new API functions for directory switching
lua/fff/fuzzy.lua Exposes the new restart_index_in_path function from Rust module
Comments suppressed due to low confidence (2)

lua/fff/rust/lib.rs:49

  • [nitpick] The function name reinit_file_picker_internal is ambiguous about what 'internal' means. Consider renaming to reinitialize_file_picker or reset_file_picker_with_path for clarity.
fn reinit_file_picker_internal(path: std::path::PathBuf) -> Result<(), Error> {

lua/fff/main.lua:483

  • [nitpick] The function name changed_indexing_directory uses past tense which is confusing for an action function. Consider renaming to change_indexing_directory or set_indexing_directory.
function M.changed_indexing_directory(new_path)

Comment thread lua/fff/rust/lib.rs
Comment thread lua/fff/main.lua Outdated
closes #20

This allows to use

```
require('fff.main').find_files_in_dir('/Users/neogoose/dev/lightsource')
```

to change cwd and start the picker immediately to choose the file.
@dmtrKovalenko dmtrKovalenko merged commit d3e34a7 into main Aug 2, 2025
6 checks passed
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.

find_files_in_dir not work!

2 participants