Skip to content

fix: add nil safety checks in ft.contains and ft.calculate#522

Open
yvng-jie wants to merge 1 commit into
numToStr:masterfrom
yvng-jie:fix/ft-nil-safe
Open

fix: add nil safety checks in ft.contains and ft.calculate#522
yvng-jie wants to merge 1 commit into
numToStr:masterfrom
yvng-jie:fix/ft-nil-safe

Conversation

@yvng-jie
Copy link
Copy Markdown

  • Add nil guard in ft.contains() to prevent 'attempt to index nil' error when treesitter tree is not yet parsed
  • Add nil check for lang in ft.calculate() to fall back to filetype-based commentstring when treesitter parsing fails
  • Fix error handler in utils.lua to use tostring(err) instead of err.msg, since Lua errors are strings not objects

- Add nil guard in ft.contains() to prevent 'attempt to index nil' error
  when treesitter tree is not yet parsed
- Add nil check for lang in ft.calculate() to fall back to filetype-based
  commentstring when treesitter parsing fails
- Fix error handler in utils.lua to use tostring(err) instead of err.msg,
  since Lua errors are strings not objects
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant