Repository navigation
Conversation
…lling Add a `_shouldCancel()` hook to `Prompt` so a prompt can skip a cancel action. `AutocompletePrompt` uses it to clear a non-empty search input instead of cancelling; a second Escape on the empty input cancels as before. Selections in multiple mode are kept. Ctrl+C always cancels. The behaviour can be turned off with `clearOnCancel: false`, which the `path` prompt uses so Escape still cancels it. `_clearUserInput()` now moves the readline cursor to the end of the line before deleting, so the whole input is cleared even when the cursor is not at the end. Closes bombshell-dev#519
🦋 Changeset detectedLatest commit: c8d55e4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Escape in
autocompleteandautocompleteMultiselectnow clears the search text if there is any. It only cancels once the search is empty. Selections are kept, so you can filter, Tab a few items, Escape, and filter again (the use case in the issue).This follows the approach suggested in the issue: the per-prompt decision lives in a hook on the cancel action, not in a special case for Escape.
Promptgets a_shouldCancel(char, key)hook. It returnstrueby default and works like the existing_shouldSubmit.AutocompletePromptoverrides it. If the input has text, it clears it and does not cancel. Ctrl+C (\x03) always cancels.clearOnCancel(defaulttrue), on coreAutocompleteOptionsand on the prompts' shared autocomplete options.pathpassesclearOnCancel: false, so Escape still cancels it. Its input always holds a path (the root by default), so clearing it would leave the user with no suggestions._clearUserInput()now sends Ctrl+E before Ctrl+U. Ctrl+U only deletes text to the left of the cursor, so if the user had moved the cursor left, part of the input stayed in readline and came back on the next keypress.Decisions to review:
clearOnCancel: falseto keep the old behaviour.Closes #519
Type of change
Checklist
pnpm testpasses (or targeted tests for my change)pnpm formathas been runWhat was run locally (Node v26.10.0, pnpm 10.33.0, macOS):
pnpm test(builds first): core 177 passed, prompts 620 passed.pnpm types: clean.npx biome check .: no issues.pnpm deps(knip): clean.main(Escape cancels the prompt, and with the cursor moved left the input is not fully cleared).pathopt-out makes the existingpath"can cancel" and "renders cancelled value if one set" tests fail. The guide tests fail too.dist: typeba, Esc,c, Enter givescherry.autocompleteMultiselectwithg, Tab, Esc,o, Tab, Enter gives["grape","orange"]. Two Escapes cancel. Onmainthe same keystrokes cancel the first prompt.AI-generated code disclosure