sublimelsp / LSP-vue

Vue support for Sublime's LSP plugin
MIT License
29 stars 3 forks source link

Crash on processing diagnostics with range without end character offset #26

Closed rchl closed 4 years ago

rchl commented 4 years ago

LSP master - 131c8f1d5c966cb1315e61dd52cdb95b468bfda7 OSX LSP-vue

vetur returns one of the diagnostics with None end character offset which triggers an exception.

Here is that diagnostic:

{'source': 'Vetur', 'message': "'this' implicitly has type 'any' because it does not have a type annotation.", 'code': 2683, 'range': {'start': {'line': 6, 'character': 12}, 'end': {'line': 60, 'character': None}}, 'severity': 1}

Stacktrace:

Error handling notification textDocument/publishDiagnostics
Traceback (most recent call last):
  File "/Users/../Packages/LSP/plugin/core/rpc.py", line 277, in request_or_notification_handler
    handler(params)
  File "/Users/../Packages/LSP/plugin/core/windows.py", line 543, in <lambda>
    lambda params: self.diagnostics.receive(session.config.name, params))
  File "/Users/../Packages/LSP/plugin/core/diagnostics.py", line 58, in receive
    Diagnostic.from_lsp(item) for item in update.get('diagnostics', []))
  File "/Users/../Packages/LSP/plugin/core/diagnostics.py", line 58, in <genexpr>
    Diagnostic.from_lsp(item) for item in update.get('diagnostics', []))
  File "/Users/../Packages/LSP/plugin/core/protocol.py", line 432, in from_lsp
    Range.from_lsp(lsp_diagnostic['range']),
  File "/Users/../Packages/LSP/plugin/core/protocol.py", line 343, in from_lsp
    return Range(Point.from_lsp(range['start']), Point.from_lsp(range['end']))
  File "/Users/../Packages/LSP/plugin/core/protocol.py", line 318, in from_lsp
    return Point(point['line'], point['character'])
  File "/Users/../Packages/LSP/plugin/core/protocol.py", line 306, in __init__
    self.col = int(col)
TypeError: int() argument must be a string or a number, not 'NoneType'
predragnikolic commented 4 years ago

Either it is a bag on the server or vls is not following the spec :)


/**
     * Character offset on a line in a document (zero-based). Assuming that the line is
     * represented as a string, the `character` value represents the gap between the
     * `character` and `character + 1`.
     *
     * If the character value is greater than the line length it defaults back to the
     * line length.
     */
    character: number;
}
rchl commented 4 years ago

I've checked in VSCode and the range is fine in their version of VLS. I guess it must be slightly newer (vls package appears to be lagging slightly compared to the vscode extension). Screenshot 2020-04-13 at 23 07 23

rwols commented 4 years ago

Huh. I did not know you could transfer issues!

rchl commented 4 years ago

Not sure how to reproduce this anymore so I'll assume it's fixed.