once command has a space, strict match instead of fuzzy match

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21833/head
Michael Telatynski 2018-06-18 17:37:55 +01:00
parent a50f6094cc
commit a8520335ef
No known key found for this signature in database
GPG Key ID: 3F879DA5AD802A5E
1 changed files with 20 additions and 2 deletions

View File

@ -128,8 +128,26 @@ export default class CommandProvider extends AutocompleteProvider {
const {command, range} = this.getCurrentCommand(query, selection); const {command, range} = this.getCurrentCommand(query, selection);
if (!command) return []; if (!command) return [];
// if the query is just `/` (and the user hit TAB or waits), show them all COMMANDS otherwise FuzzyMatch them let matches;
const matches = query === '/' ? COMMANDS : this.matcher.match(command[1]); 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];
}
}
// If we don't yet have matches
if (!matches) {
if (query === '/') {
// If they have just entered `/` show everything
matches = COMMANDS;
} else {
// otherwise fuzzy match against all of the fields
matches = this.matcher.match(command[1]);
}
}
return matches.map((result) => { return matches.map((result) => {
return { return {
// If the command is the same as the one they entered, we don't want to discard their arguments // If the command is the same as the one they entered, we don't want to discard their arguments