@@ -12,13 +12,8 @@ const TextEditorPanel: React.FC<TextEditorPanelProps> = (props: TextEditorPanelP
12
12
const editorRef = React . useRef < monaco . editor . IStandaloneCodeEditor | null > ( null ) ;
13
13
const idxRef = React . useRef ( props . idx ) ;
14
14
15
- const getIdx = ( ) => {
16
- return props . idx ;
17
- }
18
-
19
15
const updateEditor = ( ) => {
20
16
editorRef . current ?. setValue ( scriptEditor . getScript ( scriptEditor . getId ( props . idx ) ) ) ;
21
- console . log ( props . idx , scriptEditor . getScript ( scriptEditor . getId ( props . idx ) ) ) ;
22
17
}
23
18
24
19
const applyPreferences = ( ) => {
@@ -42,10 +37,12 @@ const TextEditorPanel: React.FC<TextEditorPanelProps> = (props: TextEditorPanelP
42
37
}
43
38
}
44
39
45
- if ( idxRef . current != props . idx ) {
46
- idxRef . current = props . idx ;
47
- updateEditor ( ) ;
48
- }
40
+ React . useEffect ( ( ) => {
41
+ if ( idxRef . current != props . idx ) {
42
+ idxRef . current = props . idx ;
43
+ updateEditor ( ) ;
44
+ }
45
+ } , [ props . idx ] ) ;
49
46
50
47
React . useEffect ( ( ) => {
51
48
const container = document . getElementById ( 'container' ) ;
@@ -70,8 +67,7 @@ const TextEditorPanel: React.FC<TextEditorPanelProps> = (props: TextEditorPanelP
70
67
// });
71
68
72
69
editorRef . current ?. getModel ( ) ?. onDidChangeContent ( event => {
73
- scriptEditor . setScript ( scriptEditor . getId ( getIdx ( ) ) , editorRef . current ?. getValue ( ) ?? '' ) ;
74
- console . log ( getIdx ( ) , scriptEditor . getId ( getIdx ( ) ) , editorRef . current ?. getValue ( ) ?? '' , scriptEditor . getScript ( scriptEditor . getId ( props . idx ) ) ) ;
70
+ scriptEditor . setScript ( scriptEditor . getId ( idxRef . current ) , editorRef . current ?. getValue ( ) ?? '' ) ;
75
71
} ) ;
76
72
77
73
window . chrome . webview . addEventListener ( 'message' , onMessageFromNative ) ;
0 commit comments