-
Notifications
You must be signed in to change notification settings - Fork 271
fix: infinite recursion in empty folder with hide_root_node = true
#729
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
Changes from all commits
4bc0609
9a82dff
2182e72
f5ed1fd
903d9b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -216,6 +216,7 @@ create_nodes = function(source_items, state, level) | |
| extra = item.extra, | ||
| is_nested = item.is_nested, | ||
| skip_node = item.skip_node, | ||
| is_empty_with_hidden_root = item.is_empty_with_hidden_root, | ||
| -- TODO: The below properties are not universal and should not be here. | ||
| -- Maybe they should be moved to the "extra" field? | ||
| is_link = item.is_link, | ||
|
|
@@ -315,7 +316,13 @@ end | |
|
|
||
| local prepare_node = function(item, state) | ||
| if item.skip_node then | ||
| return nil | ||
| if item.is_empty_with_hidden_root then | ||
| local line = NuiLine() | ||
| line:append("(empty folder)", highlights.MESSAGE) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Would setting the type of the node to
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ya setting the type to message should work. When you say
What do you mean? A side note, if we completely remove the changes that are being proposed to the renderer, your solution still works. I don't know that we need to be touching renderer at all (aside from the nil bug I mentioned earlier, though I can submit a PR for that if we want as its outside the scope of this issue).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
with this patch, --- a/lua/neo-tree/ui/renderer.lua
+++ b/lua/neo-tree/ui/renderer.lua
@@ -317,9 +317,8 @@ end
local prepare_node = function(item, state)
if item.skip_node then
if item.is_empty_with_hidden_root then
- local line = NuiLine()
- line:append("(empty folder)", highlights.MESSAGE)
- return line
+ item.type = "message"
+ return "(empty folder)"
else
return nil
end
On my end, the hang is gone, but the created file ends up in
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems I got lost while looking at the PR, I was getting the changes in |
||
| return line | ||
| else | ||
| return nil | ||
| end | ||
| end | ||
| -- pre_render is used to calculate the longest node width | ||
| -- without actually rendering the node. | ||
|
|
@@ -1074,7 +1081,6 @@ M.show_nodes = function(sourceItems, state, parentId, callback) | |
| --local id = string.format("show_nodes %s:%s [%s]", state.name, state.force_float, state.tabnr) | ||
| --utils.debounce(id, function() | ||
| events.fire_event(events.BEFORE_RENDER, state) | ||
| local is_empty_with_hidden_root = false | ||
| state.longest_width_exact = 0 | ||
| local parent | ||
| local level = 0 | ||
|
|
@@ -1093,10 +1099,8 @@ M.show_nodes = function(sourceItems, state, parentId, callback) | |
| if config.hide_root_node then | ||
| if not parentId then | ||
| sourceItems[1].skip_node = true | ||
| if sourceItems[1].children and #sourceItems[1].children > 0 then | ||
| is_empty_with_hidden_root = false | ||
| else | ||
| is_empty_with_hidden_root = true | ||
| if not (sourceItems[1].children and #sourceItems[1].children > 0) then | ||
| sourceItems[1].is_empty_with_hidden_root = true | ||
| end | ||
| end | ||
| if not config.retain_hidden_root_indent then | ||
|
|
@@ -1163,17 +1167,6 @@ M.show_nodes = function(sourceItems, state, parentId, callback) | |
| if sourceItems then | ||
| -- normal path | ||
| local nodes = create_nodes(sourceItems, state, level) | ||
| if is_empty_with_hidden_root then | ||
| local nodeData = { | ||
| id = state.path .. "_empty_message", | ||
| name = "(empty folder)", | ||
| type = "message", | ||
| level = 0, | ||
| is_last_child = true, | ||
| } | ||
| local node = NuiTree.Node(nodeData, {}) | ||
| table.insert(nodes, node) | ||
| end | ||
| draw(nodes, state, parentId) | ||
| else | ||
| -- this was a force grouping of a lazy loaded folder | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.