-
-
Notifications
You must be signed in to change notification settings - Fork 611
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
fix: bookmark filter shows marked directory children #2719
Conversation
Yes. That would be a lot faster and cleaner, which is desirable as this is a critical path function. We definitely don't want to make alny filesystem calls. The node contains that information however we don't always have a node when calling this method, hence it is called with absolute path only. Looking at the call sites we could add a |
I'm not sure what |
That's it. It is returned by libuv filesystem calls https://github.com/luvit/luv/blob/master/docs.md#uvfs_statpath-callback and has a field
It's retained by the node nvim-tree.lua/lua/nvim-tree/node.lua Line 9 in 6a99f5a
Node has a string type as well, however that's to identify the class of the node and cannot be used for our purposes.
All of the filter call sites have access to
|
I think see: https://github.com/luvit/luv/blob/master/docs.md#uvfs_statpath-callback
Currently, only one nvim-tree.lua/lua/nvim-tree/explorer/explore.lua Lines 14 to 42 in e20966a
vim.loop.fs_scandir_next(handle) only provide name and type
Which means we will have to call My current approach only uses I believe it's ready to merge if there's nothing else to concern. |
Right you are, that's a handle. The Many thanks for taking the time to identify this one. |
It looks like we can add RE
|
If you'd like to take on the above task I would be most grateful, however I understand that this is outside the scope of this change. If you choose not to we can merge this now and I'll raise an issue. |
@@ -79,9 +79,18 @@ local function bookmark(path, bookmarks) | |||
|
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.
In the interests of efficiency let's return early in the first line if bookmarks is empty or nil.
That will avoid the first utils.path_add_trailing
FYI nvim 0.10 will be providing full luadoc api coverage including uv, lsp etc. That would have made this PR much easier... |
Did you mean we will have type and intellisense for vim api functions? |
Quick summary for few changes I have made:
|
Yes. I'm quite excited. It's anything |
@@ -139,17 +156,18 @@ function M.prepare(git_status) | |||
end | |||
|
|||
for _, node in pairs(marks.get_marks()) do | |||
status.bookmarks[node.absolute_path] = true | |||
status.bookmarks[node.absolute_path] = node.type |
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.
Nicely efficient.
Future PR: create a proper class for the return. It will be done when we apply all the 0.10 annotations and the enum is present.
@@ -6,6 +6,14 @@ local M = {} | |||
---@return table | |||
local function get_formatted_lines(node) | |||
local stats = node.fs_stat | |||
if stats == nil 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.
Many thanks!
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.
Just fantastic - thank you for going the extra mile with these great improvements to the codebase.
|
Currently, bookmark filter doesn't include the children of
marked directory
This PR fixes it
For now, this
assume x is a directory by adding trailing slash
approach is working fine. However, It would be better if I we knew the filetype of path and mark in the first place to skip some unnecessary checks (requiring changes fromshould_filter
function). What do you think? Is it worth the change?