Implement tab-complete for slash commands
This needed a new interface function `getOverrideSuffix()` so we didn't suffix commands at the start with ": ". All seems to work.
This commit is contained in:
parent
11025e2ba9
commit
53f31e49da
4 changed files with 59 additions and 15 deletions
|
@ -42,6 +42,14 @@ class Entry {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {?string} The suffix to override whatever the default is, or null to
|
||||
* not do this.
|
||||
*/
|
||||
getOverrideSuffix() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this entry is clicked.
|
||||
*/
|
||||
|
@ -50,6 +58,26 @@ class Entry {
|
|||
}
|
||||
}
|
||||
|
||||
class CommandEntry extends Entry {
|
||||
constructor(command) {
|
||||
super(command);
|
||||
}
|
||||
|
||||
getKey() {
|
||||
return this.getText();
|
||||
}
|
||||
|
||||
getOverrideSuffix() {
|
||||
return " "; // force a space after the command.
|
||||
}
|
||||
}
|
||||
|
||||
CommandEntry.fromStrings = function(commandArray) {
|
||||
return commandArray.map(function(cmd) {
|
||||
return new CommandEntry(cmd);
|
||||
});
|
||||
}
|
||||
|
||||
class MemberEntry extends Entry {
|
||||
constructor(member) {
|
||||
super(member.name || member.userId);
|
||||
|
@ -99,3 +127,4 @@ MemberEntry.fromMemberList = function(members) {
|
|||
|
||||
module.exports.Entry = Entry;
|
||||
module.exports.MemberEntry = MemberEntry;
|
||||
module.exports.CommandEntry = CommandEntry;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue