@@ -3,12 +3,12 @@ import deepEqual from 'deep-equal'
3
3
import { getConfiguration , onConfigurationChanged , monaco } from '@codingame/monaco-editor-wrapper'
4
4
import { StandaloneServices , IThemeService } from 'vscode/services'
5
5
6
- function getCurrentThemeColor ( color : string ) : string | undefined {
6
+ function getCurrentThemeColor ( color : string ) : string | undefined {
7
7
const themeService = StandaloneServices . get ( IThemeService )
8
8
return themeService . getColorTheme ( ) . getColor ( color ) ?. toString ( )
9
9
}
10
10
11
- export function useThemeColor ( color : string ) : string | undefined {
11
+ export function useThemeColor ( color : string ) : string | undefined {
12
12
const [ colorValue , setColorValue ] = useState ( getCurrentThemeColor ( color ) )
13
13
useEffect ( ( ) => {
14
14
const disposable = StandaloneServices . get ( IThemeService ) . onDidColorThemeChange ( ( ) => {
@@ -25,7 +25,9 @@ export function useThemeColor (color: string): string | undefined {
25
25
return colorValue
26
26
}
27
27
28
- export function useUserConfiguration ( programmingLanguageId ?: string ) : Partial < monaco . editor . IEditorOptions > {
28
+ export function useUserConfiguration (
29
+ programmingLanguageId ?: string
30
+ ) : Partial < monaco . editor . IEditorOptions > {
29
31
const [ userConfiguration , setUserConfiguration ] = useState ( ( ) => getConfiguration ( ) ! )
30
32
useEffect ( ( ) => {
31
33
const updateOptions = ( ) => {
@@ -39,33 +41,36 @@ export function useUserConfiguration (programmingLanguageId?: string): Partial<m
39
41
return userConfiguration
40
42
}
41
43
42
- export function useLastValueRef < T > ( value : T ) : MutableRefObject < T > {
44
+ export function useLastValueRef < T > ( value : T ) : MutableRefObject < T > {
43
45
const ref = useRef < T > ( value )
44
46
ref . current = value
45
47
return ref
46
48
}
47
49
48
- export function useLastVersion < P extends unknown [ ] , R > ( func : ( ...args : P ) => R ) : ( ...args : P ) => R {
50
+ export function useLastVersion < P extends unknown [ ] , R > ( func : ( ...args : P ) => R ) : ( ...args : P ) => R {
49
51
const ref = useRef < ( ...args : P ) => R > ( func )
50
52
useEffect ( ( ) => {
51
53
ref . current = func
52
54
} , [ func ] )
53
55
return useCallback ( ( ...args : P ) => {
54
56
return ref . current ( ...args )
55
- // eslint-disable-next-line react-hooks/exhaustive-deps
56
57
} , [ ] )
57
58
}
58
59
59
- export function usePrevious < T > ( value : T ) : T | undefined {
60
- const ref = useRef < T > ( )
60
+ export function usePrevious < T > ( value : T ) : T | undefined {
61
+ const ref = useRef < T > ( undefined )
61
62
useEffect ( ( ) => {
62
63
ref . current = value
63
64
} , [ value ] )
64
65
return ref . current
65
66
}
66
67
67
- export function useDeepMemo < T , D extends unknown [ ] > ( memoFn : ( ) => T , deps : D , isEqual : ( a : D , b : D ) => boolean = deepEqual ) : T {
68
- const ref = useRef < { deps : D , value : T } > ( )
68
+ export function useDeepMemo < T , D extends unknown [ ] > (
69
+ memoFn : ( ) => T ,
70
+ deps : D ,
71
+ isEqual : ( a : D , b : D ) => boolean = deepEqual
72
+ ) : T {
73
+ const ref = useRef < { deps : D ; value : T } > ( undefined )
69
74
if ( ref . current == null || ! isEqual ( deps , ref . current . deps ) ) {
70
75
ref . current = { deps, value : memoFn ( ) }
71
76
}
0 commit comments