fix: spaces and uppercase characters in multiline input#534
Conversation
🦋 Changeset detectedLatest commit: 19255e0 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 |
commit: |
| const actions = ['up', 'down', 'left', 'right']; | ||
| type Action = (typeof actions)[number]; | ||
| const actionSet = new Set(actions); | ||
|
|
There was a problem hiding this comment.
This can probably be added to utils/settings as arrowKeys
| const casedChar = key.shift ? char.toUpperCase() : char; | ||
| this.#insertAtCursor(casedChar ?? ''); |
There was a problem hiding this comment.
i think this might break a couple of real cases:
- paste: terminals usually send pasted text as a stream of keypresses with
shift: falseper char. since the basePrompt.onKeypressalready lowercased char, we'd never re-uppercase here, pasted mixed case ends up all lowercase. - capslock without shift: some emulators send the upper-cased char with
shift: falsetoo, same deal.
the real root cause is thatPrompt.onKeypresslowercases char before emitting 'key'.
probably cleaner to just insert from key.sequence (the raw bytes, original case) and skip the shift dance entirely
wdyt @43081j ? 👀
There was a problem hiding this comment.
I based this on existing code here:
But I see how that use-case is different.
Let me take a closer look.
…dle case sensitivity better
|
Thank you for your feedback. The PR has been updated. Please let me know if changing how prompt.ts emits key events is not the right solution in your opinion. |
|
i'm not sure about this as it touches more than it needs to. cursor events purposely can be any i think the only changes you need are:
you have all these so i think it looks good if we drop the arrow key stuff |
Do you mean they don't need to be in the settings file or don't need special handling? Looking at the code, |
|
im saying none of the changes around "arrow keys" are needed to fix this bug |
@43081j Im curious what your suggestion to fix the space key issue is. At the moment, the multi-line key handler checks keys against There are a many valid ways to address this. Initially, I scoped the set of cursor keys to |
|
i think that is a bug in the multi-line prompt. clack/packages/core/src/prompts/multi-line.ts Lines 92 to 95 in 54be8d7 here we check that the key is an "action" key, and treat it as a cursor action if it is. but the multi-line prompt doesn't control its cursor actions based on the clack/packages/core/src/prompts/multi-line.ts Lines 47 to 58 in 54be8d7 the settings can't override that. so its basically a bug i think - that we shouldn't be checking so you were on the right track, but not as a change to the core settings or types. this is just a separate, one-off hard coded set of keys a user can't configure (specific to the multi-line prompt). |
|
@43081j updated |
What does this PR do?
Fixes multiline prompt typing so spaces and uppercase characters are inserted correctly.
See #529 for details.
Changes
Closes #529
Type of change
Checklist
pnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure