Skip to content

Commit

Permalink
adjust diagnostic column
Browse files Browse the repository at this point in the history
  • Loading branch information
rtbo committed Jun 9, 2023
1 parent d125a93 commit 5ebb700
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions source/served/linters/ccdb.d
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void lint(Document document)
auto uri = uriFromFile(command.getPath(issue.file));

Diagnostic error;
error.range = TextRange(issue.line - 1, issue.column - 1, issue.line - 1, uint.max);
error.range = TextRange(issue.line - 1, issueColumn(issue.column), issue.line - 1, uint.max);
applyDubLintType(error, issue.type);
error.source = CcdbDiagnosticSource;
error.message = issue.text;
Expand All @@ -129,8 +129,9 @@ void lint(Document document)
DiagnosticRelatedInformation related;
string otherUri = other.file != issue.file ? command.getPath(
other.file) : uri;
related.location = Location(otherUri, TextRange(other.line - 1,
other.column - 1, other.line - 1, uint.max));
related.location = Location(
otherUri, TextRange(other.line - 1, issueColumn(other.column), other.line - 1, uint.max)
);
related.message = other.text;
return related;
}).array);
Expand All @@ -151,8 +152,9 @@ void lint(Document document)
continue;

Diagnostic supplError;
supplError.range = TextRange(suppl.line - 1, suppl.column - 1, suppl.line - 1, uint
.max);
supplError.range = TextRange(
suppl.line - 1, issueColumn(suppl.column), suppl.line - 1, uint.max
);
applyDubLintType(supplError, issue.type);
supplError.source = CcdbDiagnosticSource;
supplError.message = issue.text ~ "\n" ~ suppl.text;
Expand All @@ -171,6 +173,11 @@ void lint(Document document)
while (statusp.retryAtEnd);
}

int issueColumn(const int column) pure
{
return column > 0 ? column - 1 : 0;
}

void clear()
{
diagnostics[DiagnosticSlot] = null;
Expand Down

0 comments on commit 5ebb700

Please sign in to comment.