Combine three dependency data structures into single HashSet#129
Combine three dependency data structures into single HashSet#129devind-ra wants to merge 23 commits into
Conversation
|
Hey @jkeresman01, I think I've been able to do it. Let me know if you find any issues or tweaks that I need to make. Thanks! |
jkeresman01
left a comment
There was a problem hiding this comment.
Hi @devind-ra
Sorry for slow response on this.
When I tried testing your changes I've got this 2 errors.
- When selecting unique dep for the first time.
E5108: Error executing lua: ...alizr.nvim/lua/spring-initializr/telescope/telescope.lua:165: attempt to get length of field 'selected_dependencies' (a nil value)
stack traceback:
...alizr.nvim/lua/spring-initializr/telescope/telescope.lua:165: in function 'record_selection'
...alizr.nvim/lua/spring-initializr/telescope/telescope.lua:205: in function 'on_select'
...alizr.nvim/lua/spring-initializr/telescope/telescope.lua:252: in function 'run_replace_or_original'
...packer/start/telescope.nvim/lua/telescope/actions/mt.lua:65: in function 'key_func'
...k/packer/start/telescope.nvim/lua/telescope/mappings.lua:253: in function <...k/packer/start/telescope.nvim/lua/telescope/mappings.lua:252> - When trying to remove selected dependency.
E5108: Error executing lua: ...alizr.nvim/lua/spring-initializr/telescope/telescope.lua:182: attempt to call method 'remove_key' (a nil value)
stack traceback:
...alizr.nvim/lua/spring-initializr/telescope/telescope.lua:182: in function 'remove_dependency'
...lizr/ui/components/dependencies/dependencies_display.lua:346: in function 'remove_focused_card'
...lizr/ui/components/dependencies/dependencies_display.lua:380: in function <...lizr/ui/components/dependencies/dependencies_display.lua:379>
Press ENTER or type command to continue
Didn't quite catch enough time to pinpoint exact root cause.
Could you also look it up, see if same issue is present from your side.
|
@jkeresman01, no worries. I'll look into the issue on my side as well and see what's going on. Thanks for the review |
|
@jkeresman01, apologies for the delay it was a simpler fix than I thought. Let me know how it works on your side! |
Hi first issue was resolved and I no longer see errors when selecting dependencies. Nice work on that. But second problem is still seen: Steps to reproduce:
|
This reverts commit 09e2ca7.
…tructures-into-hashset
|
Can you have a go at seeing if the dd removes the dependency on your side? I tried using that keybind but it wasn't working for me even in main. Also apologies, I committed to main to fix an issue with the HashSet. It's all reverted now and committed to here instead! |
Removing with You can just reset the form with |
Ah yep I see what you mean in that issue. With 'Ctrl + r' it seems to be working fine then on my side. |
Still doesn't work on my side. But perhaps I explained it a bit poorly in my previous message. On When I checkout your branch the removal with dd no longer works at all with latest changes. |
|
Hi @jkeresman01, sorry I've been AWOL with contributing to this. Seems to be an issue with removal which I've now carried out using a remove_by_key() method. Lmk if there is other cases I need to be testing which could cause issues! |
jkeresman01
left a comment
There was a problem hiding this comment.
Hi,
great work but few small improvements are needed.
|
Changes should be made now |
Hi, I've started testing this now and found one additional bug that needs to be fixed: The bug is in The issue is -> Lines 158-183 don't check for nil dependencies before processing them, and there's a duplicate add() call. This fixes it: -- Line 154: Initialize HashSet with key function (remove duplicate initialization)
local key_fn = function(entry)
return entry.id
end
telescope.selected_dependencies_set = HashSet.new({ key_fn = key_fn })
if project.dependencies then
for _, dep in ipairs(project.dependencies) do
-- Line 161: Add nil check here
if dep then
local entry
if type(dep) == "table" and dep.id then
entry = {
id = dep.id,
name = dep.name or dep.id,
description = dep.description or "",
group = dep.group or "",
label = string.format("[%s] %s", dep.group or "", dep.name or dep.id),
}
elseif type(dep) == "string" and dep ~= "" then -- Add empty string check
entry = {
id = dep,
name = dep,
description = "",
group = "",
label = dep,
}
end
-- Only add once (remove the duplicate add() from line 167)
if entry then
telescope.selected_dependencies_set:add(entry)
end
end
end
endChanges needed to make this work: I've tested changes with this fix and it seems to be working as expected. |
|
Thanks for spotting that, changes should be implemented from your comment |
Description
Refactoring usage in tests and files where all three data structures were used.
Fix for issue #110
Type of change
How Has This Been Tested?
Manual testing and unit tests
Configuration:
Checklist: