@@ -487,9 +487,17 @@ final class QueryViewModel {
487487 errorMessage = ParseableError.userFriendlyMessage(for: error)
488488 if let serverError = error as? ParseableError,
489489 case .serverError(_, let msg) = serverError,
490− let pos = SQLErrorPosition.parse(from: msg) {
490+ let pos = SQLErrorPosition.parse(from: msg),
491+ sqlQuery == sql {
492+ // The server's line/column is relative to the *submitted* SQL.
493+ // Only map it back into the editor when the editor still holds
494+ // that same text — if the user edited the query while it was in
495+ // flight, the position no longer corresponds to what's displayed
496+ // and would underline an unrelated span. (`sqlQuery`'s didSet
497+ // already cleared errorRange on that edit, so leaving it nil here
498+ // keeps the editor unmarked.)
491499 errorRange = SQLTokenizer.errorHighlightRange(
492− line: pos.line, column: pos.column, in: sqlQuery
500+ line: pos.line, column: pos.column, in: sql
493501 )
494502 }
495503 results = []