Skip to content

Commit 7282ae4

Browse files
committed
Remove invalid errors
Signed-off-by: worksofliam <[email protected]>
1 parent 3bf0cd6 commit 7282ae4

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/language/providers/problemProvider.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ async function validateSqlDocument(document: TextDocument, specificStatement?: n
136136
if (specificStatement) {
137137
// If specificStatement is outside this group, continue
138138
if (
139-
specificStatement < group.range.start ||
140-
(specificStatement > (allGroups[i + 1] ? allGroups[i + 1].range.start : group.range.end))
139+
(specificStatement < group.range.start && i !== 0) ||
140+
(specificStatement > (allGroups[i + 1] ? allGroups[i + 1].range.start : group.range.end) && i !== allGroups.length - 1)
141141
) {
142142
continue;
143143
}
@@ -170,7 +170,7 @@ async function validateSqlDocument(document: TextDocument, specificStatement?: n
170170

171171
if (validStatements.length > MAX_STATEMENT_COUNT) {
172172
window.showWarningMessage(`${basename}: the SQL syntax checker cannot run because the statement limit has been reached (${validStatements.length} of ${MAX_STATEMENT_COUNT} max).`);
173-
173+
174174
} else {
175175

176176
const invalidStatements = statementRanges.filter(r => !r.validate);
@@ -243,6 +243,16 @@ async function validateSqlDocument(document: TextDocument, specificStatement?: n
243243
}
244244
}
245245

246+
const lastGroup = allGroups[allGroups.length - 1];
247+
248+
if (lastGroup) {
249+
for (let i = currentErrors.length - 1; i >= 0; i--) {
250+
if (document.offsetAt(currentErrors[i].range.start) > lastGroup.range.end) {
251+
currentErrors.splice(i, 1);
252+
}
253+
}
254+
}
255+
246256
sqlDiagnosticCollection.set(document.uri, currentErrors);
247257
}
248258
}

0 commit comments

Comments
 (0)