Mermade / openapi-lint-vscode

OpenAPI 2.0/3.0.x intellisense, validator, linter, converter and resolver extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=mermade.openapi-lint
BSD 3-Clause "New" or "Revised" License
51 stars 9 forks source link

Linter crashes with missing range #32

Open bjorn-einar-bjartnes-4ss opened 3 years ago

bjorn-einar-bjartnes-4ss commented 3 years ago

Problem description

I am not sure why it fails, because it only failed like this on some machines, and from what I can see the setup was identical. However, this error occured on all our work laptops, not sure why it fails on only some machines yet...

image

RangeMustbeSet

Workaround

I "fixed" it and verifies that the plugin runs when I replace the https://github.com/Mermade/openapi-lint-vscode/blob/master/extension.js#L147 and https://github.com/Mermade/openapi-lint-vscode/blob/master/extension.js#L194

            let range; // TODO 

with

            let p1 = new vscode.Position(0,0);
            let p2 = new vscode.Position(0,0);
            let range = new vscode.Range(p1,p2); 

but I want to dig a little more into it before submitting a PR. When it fails, it is already inside an exception handler so there are no errors visible to the in VS Code, the plugin just does not work. This "fix" made it work again by printing the errors on position 0, I guess a better fix is to actually try to make the range either the error or the entire document...