File tree Expand file tree Collapse file tree 3 files changed +24
-4
lines changed
containers/Tenant/Query/QueryEditor Expand file tree Collapse file tree 3 files changed +24
-4
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+
3+ export function useCancellableFunction < T extends { cancel : ( ) => void } > ( cancellable : T ) {
4+ React . useEffect ( ( ) => {
5+ return ( ) => {
6+ cancellable . cancel ( ) ;
7+ } ;
8+ } , [ cancellable ] ) ;
9+ return cancellable ;
10+ }
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 { debounce } from 'lodash' ;
35import { MarkerSeverity , editor } from 'monaco-editor' ;
46
7+ import { useCancellableFunction } from '../hooks/useCancellable' ;
8+
59import i18n from './i18n' ;
610
711const owner = 'ydb' ;
812
913const debouncedHighlightErrors = debounce ( highlightErrors , 500 ) ;
1014
11- export function updateErrorsHighlighting ( ) {
12- unHighlightErrors ( ) ;
15+ export function useUpdateErrorsHighlighting ( ) {
16+ const highlightErrors = useCancellableFunction ( debouncedHighlightErrors ) ;
17+ const updateErrorsHighlighting = React . useCallback ( ( ) => {
18+ unHighlightErrors ( ) ;
1319
14- debouncedHighlightErrors ( ) ;
20+ highlightErrors ( ) ;
21+ } , [ highlightErrors ] ) ;
22+ return updateErrorsHighlighting ;
1523}
1624
1725function highlightErrors ( ) {
You can’t perform that action at this time.
0 commit comments