feat: Correctly handle change of cwd automatically and via API#27
Merged
Conversation
Contributor
There was a problem hiding this comment.
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_internalis ambiguous about what 'internal' means. Consider renaming toreinitialize_file_pickerorreset_file_picker_with_pathfor clarity.
fn reinit_file_picker_internal(path: std::path::PathBuf) -> Result<(), Error> {
lua/fff/main.lua:483
- [nitpick] The function name
changed_indexing_directoryuses past tense which is confusing for an action function. Consider renaming tochange_indexing_directoryorset_indexing_directory.
function M.changed_indexing_directory(new_path)
9f9bd4d to
8dc9f74
Compare
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.
8dc9f74 to
fe4bcae
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #20
This allows to use
to change cwd and start the picker immediately to choose the file.