Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Fix SQL editor highlighting wrong line if have selection (#21288)

Joshen Limfe7e66615f9e
diff --git a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
index 7b4fe14387f..1d1f53413ab 100644
--- a/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
+++ b/apps/studio/components/interfaces/SQLEditor/SQLEditor.tsx
@@ -198,9 +198,12 @@ const SQLEditor = () => {
const editor = editorRef.current
const monaco = monacoRef.current
+ const startLineNumber = hasSelection ? editor?.getSelection()?.startLineNumber ?? 0 : 0
+
const formattedError = error.formattedError ?? ''
const lineError = formattedError.slice(formattedError.indexOf('LINE'))
- const line = Number(lineError.slice(0, lineError.indexOf(':')).split(' ')[1])
+ const line =
+ startLineNumber + Number(lineError.slice(0, lineError.indexOf(':')).split(' ')[1])
if (!isNaN(line)) {
const decorations = editor?.deltaDecorations(