Skip to content

Commit 77465e9

Browse files
committed
update files to ensure consistency and fix test errors
1 parent ca26d11 commit 77465e9

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ MAILGUN_KEY=<your-mailgun-api-key>
1919
ML5_LIBRARY_USERNAME=ml5
2020
ML5_LIBRARY_EMAIL=examples@ml5js.org
2121
ML5_LIBRARY_PASS=helloml5
22-
MONGO_URL=mongodb://127.0.0.1:27017/p5js-web-editor
22+
MONGO_URL=mongodb://localhost:27017/p5js-web-editor
2323
PORT=8000
2424
PREVIEW_PORT=8002
2525
EDITOR_URL=http://localhost:8000

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

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,15 @@ class Editor extends React.Component {
419419
}
420420

421421
showHint(_cm) {
422+
if (!_cm) return;
423+
422424
if (!this.props.autocompleteHinter) {
423425
CodeMirror.showHint(_cm, () => {}, {});
424426
return;
425427
}
426428

427429
let focusedLinkElement = null;
430+
428431
const setFocusedLinkElement = (set) => {
429432
if (set && !focusedLinkElement) {
430433
const activeItemLink = document.querySelector(
@@ -439,6 +442,7 @@ class Editor extends React.Component {
439442
}
440443
}
441444
};
445+
442446
const removeFocusedLinkElement = () => {
443447
if (focusedLinkElement) {
444448
focusedLinkElement.classList.remove('focused-hint-link');
@@ -461,12 +465,8 @@ class Editor extends React.Component {
461465
);
462466
if (activeItemLink) activeItemLink.click();
463467
},
464-
Right: (cm, e) => {
465-
setFocusedLinkElement(true);
466-
},
467-
Left: (cm, e) => {
468-
removeFocusedLinkElement();
469-
},
468+
Right: (cm, e) => setFocusedLinkElement(true),
469+
Left: (cm, e) => removeFocusedLinkElement(),
470470
Up: (cm, e) => {
471471
const onLink = removeFocusedLinkElement();
472472
e.moveFocus(-1);
@@ -485,26 +485,28 @@ class Editor extends React.Component {
485485
closeOnUnfocus: false
486486
};
487487

488-
if (_cm.options.mode === 'javascript') {
489-
// JavaScript
490-
CodeMirror.showHint(
491-
_cm,
492-
() => {
493-
const c = _cm.getCursor();
494-
const token = _cm.getTokenAt(c);
495-
const hints = contextAwareHinter(_cm, { hinter: this.hinter });
496-
return {
497-
list: hints,
498-
from: CodeMirror.Pos(c.line, token.start),
499-
to: CodeMirror.Pos(c.line, c.ch)
500-
};
501-
},
502-
hintOptions
503-
);
504-
} else if (_cm.options.mode === 'css') {
505-
// CSS
506-
CodeMirror.showHint(_cm, CodeMirror.hint.css, hintOptions);
507-
}
488+
const triggerHints = () => {
489+
if (_cm.options.mode === 'javascript') {
490+
CodeMirror.showHint(
491+
_cm,
492+
() => {
493+
const c = _cm.getCursor();
494+
const token = _cm.getTokenAt(c);
495+
const hints = contextAwareHinter(_cm, { hinter: this.hinter });
496+
return {
497+
list: hints,
498+
from: CodeMirror.Pos(c.line, token.start),
499+
to: CodeMirror.Pos(c.line, c.ch)
500+
};
501+
},
502+
hintOptions
503+
);
504+
} else if (_cm.options.mode === 'css') {
505+
CodeMirror.showHint(_cm, CodeMirror.hint.css, hintOptions);
506+
}
507+
};
508+
509+
setTimeout(triggerHints, 0);
508510
}
509511

510512
showReplace() {

0 commit comments

Comments
 (0)