diff options
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/completion.js | 6 | ||||
-rw-r--r-- | src/components/console.js | 20 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/components/completion.js b/src/components/completion.js index d1fdd06..f527a84 100644 --- a/src/components/completion.js +++ b/src/components/completion.js @@ -6,15 +6,15 @@ export default class Completion { } update() { - let state = this.store.getState().completion; + let state = this.store.getState().console; if (JSON.stringify(this.prevState) === JSON.stringify(state)) { return; } this.wrapper.innerHTML = ''; - for (let i = 0; i < state.groups.length; ++i) { - let group = state.groups[i]; + for (let i = 0; i < state.completions.length; ++i) { + let group = state.completions[i]; let title = this.createCompletionTitle(group.name); this.wrapper.append(title); diff --git a/src/components/console.js b/src/components/console.js index 3a7f88b..12341c1 100644 --- a/src/components/console.js +++ b/src/components/console.js @@ -1,5 +1,5 @@ import messages from 'content/messages'; -import * as completionActions from 'actions/completion'; +import * as consoleActions from 'actions/console'; export default class ConsoleComponent { constructor(wrapper, store) { @@ -39,9 +39,9 @@ export default class ConsoleComponent { }).then(this.onBlur); case KeyboardEvent.DOM_VK_TAB: if (e.shiftKey) { - this.store.dispatch(completionActions.selectPrev()); + this.store.dispatch(consoleActions.completionPrev()); } else { - this.store.dispatch(completionActions.selectNext()); + this.store.dispatch(consoleActions.completionNext()); } e.stopPropagation(); e.preventDefault(); @@ -66,7 +66,7 @@ export default class ConsoleComponent { type: messages.CONSOLE_QUERY_COMPLETIONS, text: e.target.value }).then((completions) => { - this.store.dispatch(completionActions.setItems(completions)); + this.store.dispatch(consoleActions.setCompletions(completions)); }); } @@ -85,6 +85,18 @@ export default class ConsoleComponent { this.hideError(); } + if (state.groupSelection >= 0 && state.itemSelection >= 0) { + let group = state.completions[state.groupSelection]; + let item = group.items[state.itemSelection]; + this.setCommandValue(item.content); + } else if (state.completions.length > 0 && + JSON.stringify(this.prevState.completions) === + JSON.stringify(state.completions)) { + // Reset input only completion groups not changed (unselected an item in + // completion) in order to avoid to override previous input + this.setCommandCompletionOrigin(); + } + this.prevState = state; } |