-
-
Notifications
You must be signed in to change notification settings - Fork 638
refactor(#3225): multi instance - move expand actions to nodes #3234
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
base: master
Are you sure you want to change the base?
Conversation
Move expansion logic from actions/tree/modifiers/expand.lua into DirectoryNode and Explorer methods. Update API to use new methods via wrap_explorer. Remove expand module and its setup calls.
| ---@param should_descend fun(expansion_count: integer, node: Node): boolean | ||
| ---@return fun(expansion_count: integer, node: Node): boolean | ||
| function DirectoryNode:limit_folder_discovery(should_descend) | ||
| local MAX_FOLDER_DISCOVERY = self.explorer.opts.actions.expand_all.max_folder_discovery |
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.
Nice one. Reading it here will allow us to dynamically change actions.expand_all.max_folder_discovery
| ---@param _ integer expansion_count | ||
| ---@return boolean | ||
| function DirectoryNode:descend_until_empty(_) | ||
| local EXCLUDE = to_lookup_table(self.explorer.opts.actions.expand_all.exclude) |
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.
Again nice, allows dynamic changes to actions.expand_all.exclude
Base Test CasesSetupcd /tmp
git clone git@github.com:rvaiya/keyd.gitStartup Nvim - FailStart nvim in /tmp/keyd We have an unresovleable circular dependency, as Recommendation: remove unnecessary type testing. ---@param expand_opts ApiTreeExpandOpts?
function Node:expand(expand_opts)
if self.parent then
self.parent:expand(expand_opts)
end
endGood OO design directs that parent types should never be aware of child types. Expand Root - FailStart nvim in /tmp/keyd
Expected: root should expand until My statement "Other functions above should be private methods" in the issue is incorrect and was not properly thought out and for that I apologise.
Recommendation: revert |
alex-courtis
left a comment
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.
This is looking good, it is tidying up and encapsulating nicely.
We have a couple of test failures. Please
- resolve the circular dependency
- fix expand root
In the future please test startup, basic functionality and your changes before submitting a PR.
Description
Refactors the expand functionality by moving it from the actions layer into node methods, improving encapsulation and making the code more object-oriented.
Changes
lua/nvim-tree/actions/tree/modifiers/expand.luamoduleDirectoryNodeandExplorerclasses as methodsDirectoryNode:expand()- public method for recursive directory expansionDirectoryNode:expand_dir_node()- helper to open and load a single directoryNode:expand()- dispatcher that handles both file and directory nodesExplorer:expand_all()andExplorer:expand_node()- wrapper methods for the APIExplorermethods viawrap_explorercore.get_explorer()calls withself.explorerreferencesExplorer:expand()toExplorer:expand_dir_node()to avoid naming conflictsmodifiers.setup()as it's no longer neededBenefits
Related Issues
Closes #3225