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

Commit 60a9752

Browse files
authored
Merge pull request #2005 from matrix-org/t3chguy/fix_commands
slash got consumed in the consolidation
2 parents 2b8bc8a + 884fa3b commit 60a9752

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/SlashCommands.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ import SettingsStore, {SettingLevel} from './settings/SettingsStore';
2727

2828
class Command {
2929
constructor({name, args='', description, runFn}) {
30-
this.command = name;
30+
this.command = '/' + name;
3131
this.args = args;
3232
this.description = description;
3333
this.runFn = runFn;
3434
}
3535

3636
getCommand() {
37-
return "/" + this.command;
37+
return this.command;
3838
}
3939

4040
getCommandWithArgs() {

src/autocomplete/CommandProvider.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,14 @@ export default class CommandProvider extends AutocompleteProvider {
4141
const {command, range} = this.getCurrentCommand(query, selection);
4242
if (!command) return [];
4343

44-
let matches;
44+
let matches = [];
4545
if (command[0] !== command[1]) {
4646
// The input looks like a command with arguments, perform exact match
47-
const match = COMMANDS.find((o) => o.command === command[1]);
48-
if (match) {
49-
matches = [match];
47+
const name = command[1].substr(1); // strip leading `/`
48+
if (CommandMap[name]) {
49+
matches = [CommandMap[name]];
5050
}
51-
}
52-
53-
// If we don't yet have matches
54-
if (!matches) {
51+
} else {
5552
if (query === '/') {
5653
// If they have just entered `/` show everything
5754
matches = COMMANDS;

0 commit comments

Comments
 (0)