Skip to content

Commit 3f22c2f

Browse files
committed
fix: review
1 parent 3cf0cc1 commit 3f22c2f

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed
Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
import {parseYqlQueryWithoutCursor} from '@gravity-ui/websql-autocomplete/yql';
22
import {MarkerSeverity, editor} from 'monaco-editor';
33

4+
import i18n from './i18n';
5+
46
const owner = 'ydb';
57

68
let 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

4645
function unHighlightErrors(): void {
4746
editor.removeAllMarkers(owner);
4847
}
49-
50-
function convertAutocompleteErrorLocationIndexToMonacoIndex(
51-
autocompleteLocationIndex: number,
52-
): number {
53-
return autocompleteLocationIndex + 1;
54-
}

src/utils/monaco/i18n/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"context_syntax-error": "Syntax error"
3+
}

src/utils/monaco/i18n/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {registerKeysets} from '../../i18n';
2+
3+
import en from './en.json';
4+
5+
const COMPONENT = 'ydb-monaco';
6+
7+
export default registerKeysets(COMPONENT, {en});

0 commit comments

Comments
 (0)