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

hide some commands after space as they have special semantics #2074

Merged
merged 1 commit into from
Jul 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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