[sql lab] fix alt-enter runs out-of-date SQL (#2603)

This commit is contained in:
Maxime Beauchemin 2017-04-13 15:47:20 -07:00 committed by GitHub
parent db02b33e09
commit 6c68a21e4f

View File

@ -62,12 +62,16 @@ class AceEditorWrapper extends React.PureComponent {
onBlur() {
this.props.onBlur(this.state.sql);
}
onAltEnter() {
this.props.onBlur(this.state.sql);
this.props.onAltEnter();
}
onEditorLoad(editor) {
editor.commands.addCommand({
name: 'runQuery',
bindKey: { win: 'Alt-enter', mac: 'Alt-enter' },
exec: () => {
this.props.onAltEnter();
this.onAltEnter();
},
});
editor.$blockScrolling = Infinity; // eslint-disable-line no-param-reassign
@ -76,6 +80,9 @@ class AceEditorWrapper extends React.PureComponent {
this.props.queryEditor, editor.getSelectedText());
});
}
getCompletions(aceEditor, session, pos, prefix, callback) {
callback(null, this.state.words);
}
setAutoCompleter(props) {
// Loading table and column names as auto-completable words
let words = [];
@ -101,9 +108,6 @@ class AceEditorWrapper extends React.PureComponent {
}
});
}
getCompletions(aceEditor, session, pos, prefix, callback) {
callback(null, this.state.words);
}
textChange(text) {
this.setState({ sql: text });
}