using context signal: currentAbortController.signal, the error does not contain the last selected/ current selected
The abort error does not pass the last highlighted or selected elements along.
Problem: Last state is unknown.
For legacy Inquirer there was some rxjs way of accessing the options? or selections? Is there something similar to work araound this issue?
import { select, checkbox } from '@inquirer/prompts';
let currentAbortController = new AbortController();
setTimeout(_ => currentAbortController.abort(), 2000);
let selection = await checkbox({
message: 'Select something',
choices: choices,
}, {
signal: currentAbortController.signal,
clearPromptOnDone: true
}).catch(e => {errorWith: error.lastSelected}) ; // <-- this would be missing: error.lastSelected
if (selection.errorWith) {
console.log('errored');
selection = selection.errorWith;
}
console.log('selection', selection);
Hi, I hadn't considered this use-case. I think it's valid, but it'll need some architecting and to give some thoughts to properly typing this so it doesn't lead to undue complexity.
Possible use case: This would be useful to be able to continue a prompt (some text already written) or selection (checkboxes or alike) later, if it was aborted due to outside circumstances that need another prompt due to some intervention.
I wonder if instead of adding the value to the error, we should add an option to not throw but return the selected option once the signal exit. That'd also clean the user code VS having to catch and handle.