Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
hide some commands after space as they have special semantics
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
  • Loading branch information
t3chguy committed Jul 18, 2018
1 parent f429ae5 commit 5867fe7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/SlashCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -78,6 +79,7 @@ export const CommandMap = {
});
return success();
},
hideCompletionAfterSpace: true,
}),

nick: new Command({
Expand Down Expand Up @@ -466,6 +468,7 @@ export const CommandMap = {
name: 'me',
args: '<message>',
description: _td('Displays action'),
hideCompletionAfterSpace: true,
}),
};
/* eslint-enable babel/no-invalid-this */
Expand Down
2 changes: 2 additions & 0 deletions src/autocomplete/CommandProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5867fe7

Please sign in to comment.