use existing command hashmap over linear array search

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2018-06-20 17:25:23 +01:00
parent 7d9d17145c
commit 884fa3b913
No known key found for this signature in database
GPG key ID: 3F879DA5AD802A5E

View file

@ -44,9 +44,9 @@ export default class CommandProvider extends AutocompleteProvider {
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]];
}
} else {
if (query === '/') {