File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed
containers/Tenant/Query/QueryEditor Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ import {
4242import { useChangedQuerySettings } from '../../../../utils/hooks/useChangedQuerySettings' ;
4343import { useLastQueryExecutionSettings } from '../../../../utils/hooks/useLastQueryExecutionSettings' ;
4444import { YQL_LANGUAGE_ID } from '../../../../utils/monaco/constats' ;
45- import { updateErrorsHighlighting } from '../../../../utils/monaco/highlightErrors' ;
45+ import { useUpdateErrorsHighlighting } from '../../../../utils/monaco/highlightErrors' ;
4646import { QUERY_ACTIONS } from '../../../../utils/query' ;
4747import type { InitialPaneState } from '../../utils/paneVisibilityToggleHelpers' ;
4848import {
@@ -90,6 +90,8 @@ export default function QueryEditor(props: QueryEditorProps) {
9090 const input = useTypedSelector ( selectUserInput ) ;
9191 const showPreview = useTypedSelector ( selectShowPreview ) ;
9292
93+ const updateErrorsHighlighting = useUpdateErrorsHighlighting ( ) ;
94+
9395 const isResultLoaded = Boolean ( result ) ;
9496
9597 const [ querySettings ] = useQueryExecutionSettings ( ) ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+
13import { parseYqlQueryWithoutCursor } from '@gravity-ui/websql-autocomplete/yql' ;
24import { MarkerSeverity , editor } from 'monaco-editor' ;
35
46import i18n from './i18n' ;
57
68const owner = 'ydb' ;
79
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 ( ) ;
923
10- export function updateErrorsHighlighting ( ) {
11- unHighlightErrors ( ) ;
24+ if ( errorsHighlightingTimerRef . current ) {
25+ clearTimeout ( errorsHighlightingTimerRef . current ) ;
26+ }
27+ errorsHighlightingTimerRef . current = window . setTimeout ( ( ) => highlightErrors ( ) , 500 ) ;
28+ } , [ ] ) ;
1229
13- clearTimeout ( errorsHighlightingTimeoutId ) ;
14- errorsHighlightingTimeoutId = setTimeout ( ( ) => highlightErrors ( ) , 500 ) ;
30+ return updateErrorsHighlighting ;
1531}
1632
1733function highlightErrors ( ) {
You can’t perform that action at this time.
0 commit comments