fix(indent-hints): prevent nil function call#13
Conversation
changed with nvim 0.11 "Query:iter_matches() correctly returns all matching nodes in a match instead of only the last node. This means that the returned table maps capture IDs to a list of nodes that need to be iterated over. For backwards compatibility, an option all=false (only return the last matching node) is provided that will be removed in a future release." https://neovim.io/doc/user/news-0.11.html
WalkthroughNil checks were added for the Treesitter parser in both Changes
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
lua/helm-ls/indent-hints.lua (1)
87-89: Consider impact of early return on match processing.The early return when
tonumber(node_content)fails will skip processing the remaining nodes in the current match. This behavior might be acceptable depending on the expected query results, but consider whether partial processing of a match is the intended behavior.If you want to continue processing other nodes in the match instead of aborting completely, consider using
continuelogic:- if not indent_count then - return - end + if not indent_count then + goto continue_node + endAnd add a label at the end of the node loop:
end + ::continue_node:: end
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
lua/helm-ls/conceal.lua(1 hunks)lua/helm-ls/indent-hints.lua(2 hunks)
🔇 Additional comments (3)
lua/helm-ls/conceal.lua (1)
88-90: Good defensive programming practice.The nil check for the treesitter parser prevents runtime errors when the parser is unavailable and provides a clean early exit.
lua/helm-ls/indent-hints.lua (2)
53-55: Good defensive programming practice.The nil check for the treesitter parser prevents runtime errors when the parser is unavailable, consistent with the same change in
conceal.lua.
78-98: ```shell
#!/bin/bashShow where the Treesitter query is constructed and its capture definitions
echo "---- Query construction and captures in lua/helm-ls/indent-hints.lua ----"
rg -n "vim.treesitter.query" -A 20 -B 5 lua/helm-ls/indent-hints.lua
rg -n "captures =" -A 5 lua/helm-ls/indent-hints.luaThis will help us verify how many `func` and `args` captures exist per match and their intended order. </details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
changed with nvim 0.11
"Query:iter_matches() correctly returns all matching nodes in a match instead of only the last node. This means that the returned table maps capture IDs to a list of nodes that need to be iterated over. For backwards compatibility, an option all=false (only return the last matching node) is provided that will be removed in a future release." https://neovim.io/doc/user/news-0.11.html
Fixes #10
Summary by CodeRabbit
Bug Fixes
Refactor