From f5b12bd66ab5df55b20c81140b66fddbd3415884 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 20 Jun 2018 17:09:49 +0100 Subject: [PATCH 1/3] slash got consumed in the consolidation Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/SlashCommands.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SlashCommands.js b/src/SlashCommands.js index 3743fbb98c..211a68e7b0 100644 --- a/src/SlashCommands.js +++ b/src/SlashCommands.js @@ -27,14 +27,14 @@ import SettingsStore, {SettingLevel} from './settings/SettingsStore'; class Command { constructor({name, args='', description, runFn}) { - this.command = name; + this.command = '/' + name; this.args = args; this.description = description; this.runFn = runFn; } getCommand() { - return "/" + this.command; + return this.command; } getCommandWithArgs() { From 7d9d17145c125db962a0eff3bbcd4a065c5b403e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 20 Jun 2018 17:21:06 +0100 Subject: [PATCH 2/3] change so that if someone enters invalid command with args we strict match Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/autocomplete/CommandProvider.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/autocomplete/CommandProvider.js b/src/autocomplete/CommandProvider.js index ea271e02ff..4b24e98605 100644 --- a/src/autocomplete/CommandProvider.js +++ b/src/autocomplete/CommandProvider.js @@ -41,17 +41,14 @@ export default class CommandProvider extends AutocompleteProvider { const {command, range} = this.getCurrentCommand(query, selection); if (!command) return []; - let matches; + let matches = []; if (command[0] !== command[1]) { // The input looks like a command with arguments, perform exact match const match = COMMANDS.find((o) => o.command === command[1]); if (match) { matches = [match]; } - } - - // If we don't yet have matches - if (!matches) { + } else { if (query === '/') { // If they have just entered `/` show everything matches = COMMANDS; From 884fa3b9139a078310ed9a6162ad06c7306c8b2d Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 20 Jun 2018 17:25:23 +0100 Subject: [PATCH 3/3] use existing command hashmap over linear array search Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/autocomplete/CommandProvider.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/autocomplete/CommandProvider.js b/src/autocomplete/CommandProvider.js index 4b24e98605..891ef97d65 100644 --- a/src/autocomplete/CommandProvider.js +++ b/src/autocomplete/CommandProvider.js @@ -44,9 +44,9 @@ export default class CommandProvider extends AutocompleteProvider { let matches = []; if (command[0] !== command[1]) { // The input looks like a command with arguments, perform exact match - const match = COMMANDS.find((o) => o.command === command[1]); - if (match) { - matches = [match]; + const name = command[1].substr(1); // strip leading `/` + if (CommandMap[name]) { + matches = [CommandMap[name]]; } } else { if (query === '/') {