File tree 2 files changed +13
-10
lines changed
client/modules/IDE/components/Editor
2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -169,7 +169,6 @@ export default function useCodeMirror({
169
169
[ `${ metaKey } -.` ] : 'toggleComment' // Note: most adblockers use the shortcut ctrl+.
170
170
} ) ;
171
171
172
- console . log ( 'setting up change handlers??' , cmInstance . current ) ;
173
172
cmInstance . current . on ( 'change' , debouncedOnChange ) ;
174
173
cmInstance . current . on ( 'keyup' , onKeyUp ) ;
175
174
cmInstance . current . on ( 'keydown' , onKeyDown ) ;
Original file line number Diff line number Diff line change @@ -115,13 +115,14 @@ function Editor({
115
115
} ) ;
116
116
117
117
// Lets the parent component access file content-specific functionality...
118
- // TODO(connie) - Revisit the logic here, can we wrap this in useCallback or something?
119
- provideController ( {
120
- tidyCode : ( ) => tidyCode ( cmInstance . current ) ,
121
- showFind,
122
- showReplace,
123
- getContent
124
- } ) ;
118
+ useEffect ( ( ) => {
119
+ provideController ( {
120
+ tidyCode : ( ) => tidyCode ( cmInstance . current ) ,
121
+ showFind,
122
+ showReplace,
123
+ getContent
124
+ } ) ;
125
+ } , [ showFind , showReplace , getContent ] ) ;
125
126
126
127
// When the CM container div mounts, we set up CodeMirror.
127
128
const onContainerMounted = useCallback ( setupCodeMirrorOnContainerMounted , [ ] ) ;
@@ -149,11 +150,14 @@ function Editor({
149
150
if ( ! autocompleteHinter ) hideHinter ( cmInstance . current ) ;
150
151
} , [ autocompleteHinter ] ) ;
151
152
152
- // TODO: Should this be watching more deps?
153
+ // TODO: test this
153
154
useEffectWithComparison (
154
155
( _ , prevProps ) => {
155
156
if ( runtimeErrorWarningVisible ) {
156
- if ( consoleEvents . length !== prevProps . consoleEvents . length ) {
157
+ if (
158
+ prevProps . consoleEvents &&
159
+ consoleEvents . length !== prevProps . consoleEvents . length
160
+ ) {
157
161
consoleEvents . forEach ( ( consoleEvent ) => {
158
162
if ( consoleEvent . method === 'error' ) {
159
163
// It doesn't work if you create a new Error, but this works
You can’t perform that action at this time.
0 commit comments