Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct line number processing #113

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/features/validationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,16 @@ export default class AnsibleValidationProvider {
let diagnostics: DiagnosticsDictionary = {};
let processLine = (line: string) => {
let matches = line.match(AnsibleValidationProvider.matchExpression);
this.output.appendLine(`Found:\n${matches}`);
this.output.appendLine(`Found: ${matches}\n`);
if (matches) {
let message = matches.groups?.message ?? "unknown";
let line = parseInt(matches.groups?.line ?? "1") - 1;
let line = parseInt(matches.groups?.line ?? "0");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have a test for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact I have no tests and this will soon come to hunt me. If one of you could add even a sample test I could start adding tests. The reason for not adding tests is because I not dot know how to write them for extensions.

Anyway, this morning I proved that there is no bug in the extension and was caused by ansible/ansible-lint#1556 -- the linter will be released soon.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC the last time I had to setup tests I followed https://code.visualstudio.com/api/working-with-extensions/testing-extension

let file = this.determineMatchFile(matches.groups?.file, textDocument);
let severity = matches.groups?.severity;
let diagnostic: vscode.Diagnostic = new vscode.Diagnostic(
new vscode.Range(line, 0, line, Number.MAX_VALUE),
new vscode.Range(
new vscode.Position(line, 0),
new vscode.Position(line + 1, 0)),
message,
this.ansibleLintSeverityToVSCodeDiagnosticsSeverity(severity)
);
Expand Down