markis/vscode-code-coverage

Request textDocument/codeAction failed.

wondertalik opened this issue · 2 comments

Hello,

Thanks for your extension. Can i use your extension for dart (flutter) code? If yes i had a problem. All details i have already explained here.

I had a look in the code, and I think the issue is the use of Number.MAX_VALUE here:

new Position(detail.line - 1, Number.MAX_VALUE)

Although I'm not certain that's really a bug. VS Code seems to allow this value fine. However, it's not valid in LSP and the LSP client appears to just pass the value on as-is. I've filed an issue at microsoft/vscode-languageserver-node#761 to see whether this is considered a bug and will be fixed there.

I think a better way to handle this than using Number.MAX_VALUE would be to change:

new Range(
    new Position(detail.line - 1, 0),
    new Position(detail.line - 1, Number.MAX_VALUE)
)

To document.lineAt(detail.line - 1).range instead. This will require access to the TextDocument for a file, but it looks like that's already available in showStatus (activeTextEditor.document) here:

const file: string = activeTextEditor.document.uri.fsPath;