Merge pull request #1998 from matrix-org/t3chguy/fix_commands

slash got consumed in the consolidation
This commit is contained in:
Luke Barnard 2018-06-21 10:13:23 +01:00 committed by GitHub
commit df58715a17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 10 deletions

View file

@ -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() {

View file

@ -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];
const name = command[1].substr(1); // strip leading `/`
if (CommandMap[name]) {
matches = [CommandMap[name]];
}
}
// If we don't yet have matches
if (!matches) {
} else {
if (query === '/') {
// If they have just entered `/` show everything
matches = COMMANDS;