File tree 2 files changed +24
-6
lines changed
containers/Tenant/Query/QueryEditor
2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ import {
42
42
import { useChangedQuerySettings } from '../../../../utils/hooks/useChangedQuerySettings' ;
43
43
import { useLastQueryExecutionSettings } from '../../../../utils/hooks/useLastQueryExecutionSettings' ;
44
44
import { YQL_LANGUAGE_ID } from '../../../../utils/monaco/constats' ;
45
- import { updateErrorsHighlighting } from '../../../../utils/monaco/highlightErrors' ;
45
+ import { useUpdateErrorsHighlighting } from '../../../../utils/monaco/highlightErrors' ;
46
46
import { QUERY_ACTIONS } from '../../../../utils/query' ;
47
47
import type { InitialPaneState } from '../../utils/paneVisibilityToggleHelpers' ;
48
48
import {
@@ -90,6 +90,8 @@ export default function QueryEditor(props: QueryEditorProps) {
90
90
const input = useTypedSelector ( selectUserInput ) ;
91
91
const showPreview = useTypedSelector ( selectShowPreview ) ;
92
92
93
+ const updateErrorsHighlighting = useUpdateErrorsHighlighting ( ) ;
94
+
93
95
const isResultLoaded = Boolean ( result ) ;
94
96
95
97
const [ querySettings ] = useQueryExecutionSettings ( ) ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
1
3
import { parseYqlQueryWithoutCursor } from '@gravity-ui/websql-autocomplete/yql' ;
2
4
import { MarkerSeverity , editor } from 'monaco-editor' ;
3
5
4
6
import i18n from './i18n' ;
5
7
6
8
const owner = 'ydb' ;
7
9
8
- let errorsHighlightingTimeoutId : ReturnType < typeof setTimeout > ;
10
+ export function useUpdateErrorsHighlighting ( ) {
11
+ const errorsHighlightingTimerRef = React . useRef < number > ( ) ;
12
+
13
+ React . useEffect ( ( ) => {
14
+ return ( ) => {
15
+ if ( errorsHighlightingTimerRef . current ) {
16
+ clearTimeout ( errorsHighlightingTimerRef . current ) ;
17
+ }
18
+ } ;
19
+ } , [ ] ) ;
20
+
21
+ const updateErrorsHighlighting = React . useCallback ( ( ) => {
22
+ unHighlightErrors ( ) ;
9
23
10
- export function updateErrorsHighlighting ( ) {
11
- unHighlightErrors ( ) ;
24
+ if ( errorsHighlightingTimerRef . current ) {
25
+ clearTimeout ( errorsHighlightingTimerRef . current ) ;
26
+ }
27
+ errorsHighlightingTimerRef . current = window . setTimeout ( ( ) => highlightErrors ( ) , 500 ) ;
28
+ } , [ ] ) ;
12
29
13
- clearTimeout ( errorsHighlightingTimeoutId ) ;
14
- errorsHighlightingTimeoutId = setTimeout ( ( ) => highlightErrors ( ) , 500 ) ;
30
+ return updateErrorsHighlighting ;
15
31
}
16
32
17
33
function highlightErrors ( ) {
You can’t perform that action at this time.
0 commit comments