Skip to content

Commit

Permalink
commands: Include the " " entry as its own option
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosuav committed Jul 26, 2024
1 parent 3275983 commit 8d01829
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions httpstatic/command_gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -1684,17 +1684,8 @@ function find_tab_completion(mle) {
const linestart = content.lastIndexOf("\n", cursor - 1);
const line = content.slice(linestart === -1 ? 0 : linestart + 1, cursor); //just what's behind the cursor, not anything after it
if (line[0] === "/" && !line.includes(' ')) {
const cmds = Object.keys(slash_commands).filter(c => c.startsWith(line.slice(1)));
if (!cmds.length) return null;
if (cmds.length === 1) {
//If the command has parameters, insert a space after the command name.
//This can be recognized by having " -> " (with the trailing space) in
//the command description; with no parameters, it's just " ->" at the
//very end of the description.
const space = slash_commands[cmds[0]].includes(" -> ") ? " " : "";
return cmds[0].slice(line.length - 1) + space;
}
return cmds.map(c => c.slice(line.length - 1)).filter(Boolean);
return Object.keys(slash_commands).filter(c => c.startsWith(line.slice(1)))
.map(c => c.slice(line.length - 1) + " ");
}
}

Expand Down

0 comments on commit 8d01829

Please sign in to comment.