Skip to content

Commit 52364f4

Browse files
author
Emil Andersson
committed
move startColumn of cypher warnings
1 parent 5d17af8 commit 52364f4

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/browser/modules/Editor/Monaco.tsx

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { Bus } from 'suber'
3939

4040
import { NEO4J_BROWSER_USER_ACTION_QUERY } from 'services/bolt/txMetadata'
4141
import { CYPHER_REQUEST } from 'shared/modules/cypher/cypherDuck'
42+
import { NotificationPosition, QueryResult } from 'neo4j-driver'
4243

4344
const shouldCheckForHints = (code: string) =>
4445
code.trim().length > 0 &&
@@ -430,30 +431,26 @@ const Monaco = forwardRef<MonacoHandles, MonacoProps>(
430431
query: 'EXPLAIN ' + text,
431432
queryType: NEO4J_BROWSER_USER_ACTION_QUERY
432433
},
433-
response => {
434+
(response: { result: QueryResult; success?: boolean }) => {
434435
if (
435436
response.success === true &&
436437
response.result.summary.notifications.length > 0
437438
) {
438439
editor.setModelMarkers(model, monacoId, [
439440
...editor.getModelMarkers({ owner: monacoId }),
440441
...response.result.summary.notifications.map(
441-
({
442-
description,
443-
position: { line },
444-
title
445-
}: {
446-
description: string
447-
position: { line: number }
448-
title: string
449-
}) => ({
450-
startLineNumber: statementLineNumber + line,
451-
startColumn: 1,
452-
endLineNumber: statementLineNumber + line,
453-
endColumn: 1000,
454-
message: title + '\n\n' + description,
455-
severity: MarkerSeverity.Warning
456-
})
442+
({ description, position, title }) => {
443+
const { line, column } = position as NotificationPosition
444+
return {
445+
startLineNumber: statementLineNumber + line,
446+
// The 8 subtracted from the column on the first line is the length of 'EXPLAIN '
447+
startColumn: line === 1 ? column - 8 : column,
448+
endLineNumber: statementLineNumber + line,
449+
endColumn: 1000,
450+
message: title + '\n\n' + description,
451+
severity: MarkerSeverity.Warning
452+
}
453+
}
457454
)
458455
])
459456
}

0 commit comments

Comments
 (0)