1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-06-25 01:02:58 +02:00

Get back editor autocompletion in file mode

This commit is contained in:
Kushagra Gour
2018-10-08 15:18:33 +05:30
parent b1347690ad
commit 12c0ba3bf1
2 changed files with 38 additions and 17 deletions

View File

@ -45,7 +45,7 @@ export default class UserCodeMirror extends Component {
shouldComponentUpdate(nextProps) {
if (nextProps.prefs !== this.props.prefs) {
const { prefs } = nextProps;
console.log('updating', nextProps.options.mode);
console.log('updating CM prefs', prefs);
this.cm.setOption('indentWithTabs', prefs.indentWith !== 'spaces');
this.cm.setOption(
@ -74,7 +74,7 @@ export default class UserCodeMirror extends Component {
initEditor() {
const { options, prefs } = this.props;
console.log(100, prefs.lineWrap);
console.log(100, options);
this.cm = CodeMirror.fromTextArea(this.textarea, {
mode: options.mode,
lineNumbers: true,
@ -143,10 +143,11 @@ export default class UserCodeMirror extends Component {
this.cm.addKeyMap({
'Ctrl-Space': 'autocomplete'
});
if (!options.noAutocomplete) {
this.cm.on('inputRead', (editor, input) => {
this.cm.on('inputRead', (editor, input) => {
// Process further If this has autocompletition on and also the global
// autocomplete setting is on.
if (!this.props.options.noAutocomplete && this.props.prefs.autoComplete) {
if (
!this.props.prefs.autoComplete ||
input.origin !== '+input' ||
input.text[0] === ';' ||
input.text[0] === ',' ||
@ -157,8 +158,8 @@ export default class UserCodeMirror extends Component {
CodeMirror.commands.autocomplete(this.cm, null, {
completeSingle: false
});
});
}
}
});
this.props.onCreation(this.cm);
}