From 5867fe73dd2bb83926dd3f80094cae0cc5187697 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 18 Jul 2018 15:38:21 +0100 Subject: [PATCH] hide some commands after space as they have special semantics Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/SlashCommands.js | 5 ++++- src/autocomplete/CommandProvider.js | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/SlashCommands.js b/src/SlashCommands.js index 211a68e7b0..2401d46f03 100644 --- a/src/SlashCommands.js +++ b/src/SlashCommands.js @@ -26,11 +26,12 @@ import SettingsStore, {SettingLevel} from './settings/SettingsStore'; class Command { - constructor({name, args='', description, runFn}) { + constructor({name, args='', description, runFn, hideCompletionAfterSpace=false}) { this.command = '/' + name; this.args = args; this.description = description; this.runFn = runFn; + this.hideCompletionAfterSpace = hideCompletionAfterSpace; } getCommand() { @@ -78,6 +79,7 @@ export const CommandMap = { }); return success(); }, + hideCompletionAfterSpace: true, }), nick: new Command({ @@ -466,6 +468,7 @@ export const CommandMap = { name: 'me', args: '', description: _td('Displays action'), + hideCompletionAfterSpace: true, }), }; /* eslint-enable babel/no-invalid-this */ diff --git a/src/autocomplete/CommandProvider.js b/src/autocomplete/CommandProvider.js index 5582b57e14..ca1bbb0b21 100644 --- a/src/autocomplete/CommandProvider.js +++ b/src/autocomplete/CommandProvider.js @@ -46,6 +46,8 @@ export default class CommandProvider extends AutocompleteProvider { // The input looks like a command with arguments, perform exact match const name = command[1].substr(1); // strip leading `/` if (CommandMap[name]) { + // some commands, namely `me` and `ddg` don't suit having the usage shown whilst typing their arguments + if (!CommandMap[name].hideCompletionAfterSpace) return []; matches = [CommandMap[name]]; } } else {