You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, really nice plugin, I love using it.
The other day I tried to use it on a JSON file. I forgot it wasn't possible to comment JSON, but after I did I received this error message:
E5108: Error executing lua Vim(lua):E5108: Error executing lua .../site/pack/packer/opt/Comment.nvim/lua/Comment/utils.lua:156: [Comment] Invalid commentstring - "". Run :h 'commentstring' for help.
stack traceback:
[C]: in function 'assert'
.../site/pack/packer/opt/Comment.nvim/lua/Comment/utils.lua:156: in function 'parse_cstr'
...site/pack/packer/opt/Comment.nvim/lua/Comment/optfunc.lua:62: in function 'opfunc'
...im/site/pack/packer/opt/Comment.nvim/lua/Comment/api.lua:279: in function 'current'
[string ":lua"]:1: in main chunk
[C]: at 0x55d7ba838e46
stack traceback:
[C]: at 0x55d7ba838e46
It's totally correct for the plugin to refuse to comment in a language that hasn't that feature.
But what I would suggest is avoiding to crash and break the user experience.
The plugin could show a yellow message under the statusline with something like
Comment.nvim: commenting unsupported
For example, in nvim-lspconfig, when a Language Server crashes, it's reported this way.
The plugin could show a yellow message under the statusline with something like
commenting unsupported doesn't provide any info on why the filetype is not supported. So I believe the current error message is very clear and helpful.
But what I would suggest is avoiding to crash and break the user experience.
It's "impossible" to get this error/crash unless you try something funny like comment json or text file, which i would call undefined behavior, in that case this panic make sense to me. And second reason for using assert here is to keep the code simple, rather than checking for commentstring at multiple places, i let it panic and abort the current function execution.
Activity
numToStr commentedon Aug 21, 2022
Here's my take:
commenting unsupporteddoesn't provide any info on why the filetype is not supported. So I believe the current error message is very clear and helpful.It's "impossible" to get this error/crash unless you try something funny like comment json or text file, which i would call undefined behavior, in that case this panic make sense to me. And second reason for using
asserthere is to keep the code simple, rather than checking for commentstring at multiple places, i let it panic and abort the current function execution.Comment.nvim/lua/Comment/utils.lua
Line 176 in 350bf0c