11import { parseYqlQueryWithoutCursor } from '@gravity-ui/websql-autocomplete/yql' ;
22import { MarkerSeverity , editor } from 'monaco-editor' ;
33
4+ import i18n from './i18n' ;
5+
46const owner = 'ydb' ;
57
68let errorsHighlightingTimeoutId : ReturnType < typeof setTimeout > ;
79
8- export function disableErrorsHighlighting ( ) : void {
10+ export function updateErrorsHighlighting ( ) {
911 unHighlightErrors ( ) ;
10- }
11-
12- export function updateErrorsHighlighting ( ) : void {
13- disableErrorsHighlighting ( ) ;
1412
1513 clearTimeout ( errorsHighlightingTimeoutId ) ;
1614 errorsHighlightingTimeoutId = setTimeout ( ( ) => highlightErrors ( ) , 500 ) ;
1715}
1816
19- function highlightErrors ( ) : void {
17+ function highlightErrors ( ) {
2018 const model = window . ydbEditor ?. getModel ( ) ;
2119 if ( ! model ) {
2220 console . error ( 'unable to retrieve model when highlighting errors' ) ;
@@ -29,26 +27,21 @@ function highlightErrors(): void {
2927 return ;
3028 }
3129
32- const markers = errors . map (
33- ( error ) : editor . IMarkerData => ( {
34- message : 'Syntax error' ,
30+ const markers = errors . map ( ( error ) : editor . IMarkerData => {
31+ const markerColumn = error . startColumn + 1 ;
32+ return {
33+ message : i18n ( 'context_syntax-error' ) ,
3534 source : error . message ,
3635 severity : MarkerSeverity . Error ,
3736 startLineNumber : error . startLine ,
38- startColumn : convertAutocompleteErrorLocationIndexToMonacoIndex ( error . startColumn ) ,
37+ startColumn : markerColumn ,
3938 endLineNumber : error . endLine ,
40- endColumn : convertAutocompleteErrorLocationIndexToMonacoIndex ( error . endColumn ) ,
41- } ) ,
42- ) ;
39+ endColumn : markerColumn ,
40+ } ;
41+ } ) ;
4342 editor . setModelMarkers ( model , owner , markers ) ;
4443}
4544
4645function unHighlightErrors ( ) : void {
4746 editor . removeAllMarkers ( owner ) ;
4847}
49-
50- function convertAutocompleteErrorLocationIndexToMonacoIndex (
51- autocompleteLocationIndex : number ,
52- ) : number {
53- return autocompleteLocationIndex + 1 ;
54- }
0 commit comments