@@ -3,12 +3,12 @@ import deepEqual from 'deep-equal'
33import { getConfiguration , onConfigurationChanged , monaco } from '@codingame/monaco-editor-wrapper'
44import { StandaloneServices , IThemeService } from 'vscode/services'
55
6- function getCurrentThemeColor ( color : string ) : string | undefined {
6+ function getCurrentThemeColor ( color : string ) : string | undefined {
77 const themeService = StandaloneServices . get ( IThemeService )
88 return themeService . getColorTheme ( ) . getColor ( color ) ?. toString ( )
99}
1010
11- export function useThemeColor ( color : string ) : string | undefined {
11+ export function useThemeColor ( color : string ) : string | undefined {
1212 const [ colorValue , setColorValue ] = useState ( getCurrentThemeColor ( color ) )
1313 useEffect ( ( ) => {
1414 const disposable = StandaloneServices . get ( IThemeService ) . onDidColorThemeChange ( ( ) => {
@@ -25,7 +25,9 @@ export function useThemeColor (color: string): string | undefined {
2525 return colorValue
2626}
2727
28- export function useUserConfiguration ( programmingLanguageId ?: string ) : Partial < monaco . editor . IEditorOptions > {
28+ export function useUserConfiguration (
29+ programmingLanguageId ?: string
30+ ) : Partial < monaco . editor . IEditorOptions > {
2931 const [ userConfiguration , setUserConfiguration ] = useState ( ( ) => getConfiguration ( ) ! )
3032 useEffect ( ( ) => {
3133 const updateOptions = ( ) => {
@@ -39,33 +41,36 @@ export function useUserConfiguration (programmingLanguageId?: string): Partial<m
3941 return userConfiguration
4042}
4143
42- export function useLastValueRef < T > ( value : T ) : MutableRefObject < T > {
44+ export function useLastValueRef < T > ( value : T ) : MutableRefObject < T > {
4345 const ref = useRef < T > ( value )
4446 ref . current = value
4547 return ref
4648}
4749
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 {
4951 const ref = useRef < ( ...args : P ) => R > ( func )
5052 useEffect ( ( ) => {
5153 ref . current = func
5254 } , [ func ] )
5355 return useCallback ( ( ...args : P ) => {
5456 return ref . current ( ...args )
55- // eslint-disable-next-line react-hooks/exhaustive-deps
5657 } , [ ] )
5758}
5859
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 )
6162 useEffect ( ( ) => {
6263 ref . current = value
6364 } , [ value ] )
6465 return ref . current
6566}
6667
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 )
6974 if ( ref . current == null || ! isEqual ( deps , ref . current . deps ) ) {
7075 ref . current = { deps, value : memoFn ( ) }
7176 }
0 commit comments