Skip to content

Commit 334ca17

Browse files
author
Emil Andersson
committed
use column positions from queriesAndCommands
1 parent bb7bb76 commit 334ca17

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/browser/custom.d.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,20 @@ declare module 'cypher-editor-support' {
118118
setSchema(schema: EditorSupportSchema): void
119119
update(input: string): void
120120
}
121+
interface CypherPosition {
122+
column: number
123+
line: number
124+
}
125+
export interface QueryOrCommand {
126+
getText: () => string
127+
start: CypherPosition
128+
stop: CypherPosition
129+
}
121130
export function parse(
122131
input: string
123132
): {
124133
referencesListener: {
125-
queriesAndCommands: { getText: () => string; start: { line: number } }[]
134+
queriesAndCommands: QueryOrCommand[]
126135
}
127136
}
128137
export function extractStatements(

src/browser/modules/Editor/Monaco.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020

2121
import { QuickInputList } from 'monaco-editor/esm/vs/base/parts/quickinput/browser/quickInputList'
22-
import { parse } from 'cypher-editor-support'
22+
import { parse, QueryOrCommand } from 'cypher-editor-support'
2323
import { debounce } from 'lodash-es'
2424
import {
2525
editor,
@@ -406,9 +406,7 @@ const Monaco = forwardRef<MonacoHandles, MonacoProps>(
406406
debouncedUpdateCode()
407407
}
408408

409-
const addWarnings = (
410-
statements: { start: { line: number }; getText: () => string }[]
411-
) => {
409+
const addWarnings = (statements: QueryOrCommand[]) => {
412410
if (!statements.length) return
413411

414412
const model = editorRef.current?.getModel() as editor.ITextModel
@@ -463,9 +461,11 @@ const Monaco = forwardRef<MonacoHandles, MonacoProps>(
463461
return {
464462
startLineNumber: statementLineNumber + line,
465463
// The 8 subtracted from the column on the first line is the length of 'EXPLAIN '
466-
startColumn: line === 1 ? column - 8 : column,
467-
endLineNumber: statementLineNumber + line,
468-
endColumn: 1000,
464+
startColumn:
465+
statement.start.column +
466+
(line === 1 ? column - 8 : column),
467+
endLineNumber: statement.stop.line,
468+
endColumn: statement.stop.column + 2,
469469
message: title + '\n\n' + description,
470470
severity: MarkerSeverity.Warning
471471
}

0 commit comments

Comments
 (0)