dmmulroy / ts-error-translator.nvim

MIT License
241 stars 5 forks source link

error occuring sometimes: `/init.lua:57: bad argument #2 to 'gsub'` #17

Open chrisgrieser opened 8 months ago

chrisgrieser commented 8 months ago

only created by certain diagnostics.

  Error  Error executing vim.schedule lua callback: ...s-error-translator.nvim/lua/ts-error-translator/init.lua:57: bad argument #2 to 'gsub' (string/function/table expected)
stack traceback:
    [C]: in function 'gsub'
    ...s-error-translator.nvim/lua/ts-error-translator/init.lua:57: in function 'translate_error_message'
    ...s-error-translator.nvim/lua/ts-error-translator/init.lua:125: in function 'translate'
    ...s-error-translator.nvim/lua/ts-error-translator/init.lua:151: in function 'handler'
    ...w/Cellar/neovim/0.9.5/share/nvim/runtime/lua/vim/lsp.lua:1056: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>
dmmulroy commented 8 months ago

Thank you for the reported issue and sorry you're bumping in to it - any chance you know of a minimal way to reproduce?

chrisgrieser commented 8 months ago

Been trying a bit for the last few minutes, but it's part of a bigger project, so kinda hard to separate out.

What I can tell from enabling/disabling the plugin is that it appears that this diagnostic causes it (text from when ts-error-translator is disabled)

Argument of type 'LoomColumn' is not assignable to parameter of type '{ id: string; width: string; content: string; sortDir: string; isVisible: boolean; type: string; numberPrefix: string; numberSuffix: string; numberSeparator: string; numberFormat: string; currencyType: string; ... 10 more ...; frontmatterKey: null; }'.
  Types of property 'frontmatterKey' are incompatible.
    Type 'string | null' is not assignable to type 'null'.
      Type 'string' is not assignable to type 'null'. typescript: 2345
dmmulroy commented 8 months ago

Thank you! that's super helpful, I also just pushed this commit: https://github.com/dmmulroy/ts-error-translator.nvim/commit/779410734b0be3df3f25bf94200711f0b2635a8d which should prevent this plugin from crashing until I have a better fix

dmmulroy commented 8 months ago

I made some naive assumptions about line breaks - Will hopefully have a proper fix in tonight after work, thanks again for the report.