u
This commit is contained in:
@@ -29,9 +29,10 @@ import {
|
||||
makeTheme,
|
||||
} from '@inquirer/core';
|
||||
|
||||
import { filterCommands } from './slash-commands.js';
|
||||
import { COMMANDS, filterCommands } from './slash-commands.js';
|
||||
|
||||
const MAX_SUGGESTIONS = 6;
|
||||
const NAME_WIDTH = Math.max(...COMMANDS.map((c) => c.name.length));
|
||||
|
||||
/** Show the inline menu only while the first word is being typed (no space yet). */
|
||||
function termFrom(line) {
|
||||
@@ -43,8 +44,8 @@ function termFrom(line) {
|
||||
/**
|
||||
* Replace readline's actual edit buffer, not just the visible terminal line.
|
||||
* `rl.clearLine()` only erases terminal output; using it before `rl.write()`
|
||||
* leaves the old buffer in place and turns a completion such as `/h` into
|
||||
* `/h/help` internally.
|
||||
* leaves the old buffer in place and turns a completion such as `/p` into
|
||||
* `/p/paste` internally.
|
||||
*/
|
||||
function replaceBuffer(rl, nextValue) {
|
||||
rl.write(null, { ctrl: true, name: 'a' });
|
||||
@@ -104,7 +105,7 @@ export const autocompleteInput = createPrompt((config, done) => {
|
||||
|
||||
const lines = suggestions.map((c, i) => {
|
||||
const marker = i === active % count ? chalk.cyan('❯') : ' ';
|
||||
return ` ${chalk.cyan(marker)} ${chalk.bold(c.name.padEnd(7))} ${chalk.dim(c.description)}`;
|
||||
return ` ${chalk.cyan(marker)} ${chalk.bold(c.name.padEnd(NAME_WIDTH + 2))} ${chalk.dim(c.description)}`;
|
||||
});
|
||||
if (count > 1) {
|
||||
lines.push(chalk.dim(' ↑/↓ choose · Tab complete'));
|
||||
|
||||
Reference in New Issue
Block a user