Skip to content

Commit 908fc54

Browse files
committed
fix test error
1 parent 5b71a6c commit 908fc54

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

client/modules/IDE/components/Editor/codemirror.js

-1
Original file line numberDiff line numberDiff 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);

client/modules/IDE/components/Editor/index.jsx

+13-9
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)