Skip to content

Commit 0ad31be

Browse files
fi range
1 parent e649818 commit 0ad31be

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

crates/pgt_query_ext/src/diagnostics.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ impl SyntaxDiagnostic {
2323
message: MessageAndDescription::from(message.into()),
2424
}
2525
}
26+
27+
pub fn span(mut self, span: TextRange) -> Self {
28+
self.span = Some(span);
29+
self
30+
}
2631
}
2732

2833
impl From<pg_query::Error> for SyntaxDiagnostic {

crates/pgt_workspace/src/workspace/server/document.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,9 @@ impl<'a> StatementMapper<'a> for AnalyserDiagnosticsMapper {
252252
Ok(node) => {
253253
let plpgsql_result = parser.ast_db.get_or_cache_plpgsql_parse(&id);
254254
if let Some(Err(diag)) = plpgsql_result {
255-
(Some(node.clone()), Some(diag.clone()))
255+
// offset the pgpsql diagnostic from the parent statement start
256+
let span = diag.location().span.map(|sp| sp + range.start());
257+
(Some(node.clone()), Some(diag.span(span.unwrap_or(range))))
256258
} else {
257259
(Some(node.clone()), None)
258260
}

0 commit comments

Comments
 (0)