Skip to content

Commit

Permalink
Merge branch 'master' into byolken/support_pex
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Yolken committed Nov 30, 2016
2 parents 4efc6f8 + 32fc0ff commit 19fb0af
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions superset/assets/javascripts/SqlLab/components/AceEditorWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class AceEditorWrapper extends React.PureComponent {
componentDidMount() {
// Making sure no text is selected from previous mount
this.props.actions.queryEditorSetSelectedText(this.props.queryEditor, null);
this.setAutoCompleter();
this.setAutoCompleter(this.props);
}
componentWillReceiveProps(nextProps) {
if (!areArraysShallowEqual(this.props.tables, nextProps.tables)) {
this.setAutoCompleter();
this.setAutoCompleter(nextProps);
}
}
textChange(text) {
Expand All @@ -63,11 +63,11 @@ class AceEditorWrapper extends React.PureComponent {
this.props.queryEditor, editor.getSelectedText());
});
}
setAutoCompleter() {
setAutoCompleter(props) {
// Loading table and column names as auto-completable words
let words = [];
const columns = {};
const tables = this.props.tables || [];
const tables = props.tables || [];
tables.forEach(t => {
words.push({ name: t.name, value: t.name, score: 55, meta: 'table' });
const cols = t.columns || [];
Expand All @@ -78,13 +78,15 @@ class AceEditorWrapper extends React.PureComponent {
words = words.concat(Object.keys(columns).map(col => (
{ name: col, value: col, score: 50, meta: 'column' }
)));
this.setState({ words });
const completer = {
getCompletions: this.getCompletions.bind(this),
};
if (langTools) {
langTools.setCompleters([completer, langTools.keyWordCompleter]);
}

this.setState({ words }, () => {
const completer = {
getCompletions: this.getCompletions.bind(this),
};
if (langTools) {
langTools.setCompleters([completer, langTools.keyWordCompleter]);
}
});
}
render() {
return (
Expand Down

0 comments on commit 19fb0af

Please sign in to comment.