Closed RuslanGlaznyov closed 5 months ago
pls check if this meets your purpose
// Create a custom completer function
function customCompleter(line) {
// Get the default completer function
const defaultCompleter = repl.completer;
// Call the default completer to get its completions
const [completions, originalLine] = defaultCompleter(line);
// Add your custom completions or modify the existing ones
const customCompletions = ['apple', 'banana', 'cherry', 'date'];
const combinedCompletions = completions.concat(customCompletions);
// Return the combined completions and the original line
return [combinedCompletions, originalLine];
}
cc @nodejs/repl
It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.
pls check if this meets your purpose
// Create a custom completer function function customCompleter(line) { // Get the default completer function const defaultCompleter = repl.completer; // Call the default completer to get its completions const [completions, originalLine] = defaultCompleter(line); // Add your custom completions or modify the existing ones const customCompletions = ['apple', 'banana', 'cherry', 'date']; const combinedCompletions = completions.concat(customCompletions); // Return the combined completions and the original line return [combinedCompletions, originalLine]; }
having the same issue, where does this repl
instance come from? if it's a constructed REPLServer
, there's no way to override completer
later, if it's the repl
module it doesn't have the completer
property, so i don't think this works
what i've tried that might work is this, but it doesn't feel a great solution
const tmpReplServer = repl.start({
input: fs.createReadStream("/dev/null"),
output: fs.createWriteStream("/dev/null"),
})
const defaultCompleter = tmpReplServer.completer
tmpReplServer.close()
const replServer = repl.start({
completer: defaultCompleter, // can customize
})
Details
I implement my custom REPL, I see that we can specify
completer
function. But I don't wont to replace the existing completer I want to extend prev one. For instance, I would like to add additional autocompletion (function, let, const), but leave all perv autocompletion such as defined varsNode.js version
v18.12.1 and above
Example code
Operating system
Mac OS. m1
Scope
code, repl
Module and version
Not applicable.