File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed
client/modules/IDE/components/Editor Expand file tree Collapse file tree 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({
169169 [ `${ metaKey } -.` ] : 'toggleComment' // Note: most adblockers use the shortcut ctrl+.
170170 } ) ;
171171
172- console . log ( 'setting up change handlers??' , cmInstance . current ) ;
173172 cmInstance . current . on ( 'change' , debouncedOnChange ) ;
174173 cmInstance . current . on ( 'keyup' , onKeyUp ) ;
175174 cmInstance . current . on ( 'keydown' , onKeyDown ) ;
Original file line number Diff line number Diff line change @@ -115,13 +115,14 @@ function Editor({
115115 } ) ;
116116
117117 // 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 ] ) ;
125126
126127 // When the CM container div mounts, we set up CodeMirror.
127128 const onContainerMounted = useCallback ( setupCodeMirrorOnContainerMounted , [ ] ) ;
@@ -149,11 +150,14 @@ function Editor({
149150 if ( ! autocompleteHinter ) hideHinter ( cmInstance . current ) ;
150151 } , [ autocompleteHinter ] ) ;
151152
152- // TODO: Should this be watching more deps?
153+ // TODO: test this
153154 useEffectWithComparison (
154155 ( _ , prevProps ) => {
155156 if ( runtimeErrorWarningVisible ) {
156- if ( consoleEvents . length !== prevProps . consoleEvents . length ) {
157+ if (
158+ prevProps . consoleEvents &&
159+ consoleEvents . length !== prevProps . consoleEvents . length
160+ ) {
157161 consoleEvents . forEach ( ( consoleEvent ) => {
158162 if ( consoleEvent . method === 'error' ) {
159163 // 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