mirror of
https://github.com/stablyai/orca.git
synced 2026-10-17 00:03:08 +00:00
fix(mobile): drop smart-dash write-back recovery that kills iOS dictation
The longer-hyphen recovery path (#5222) reconstructed runs by writing a value that differed from the native field text. After #7933 stores raw field text and normalizes only on send/PTY, that recovery is unreachable and any write-back would reintroduce dictation kill. Map each smart dash to exactly "--" with a single-arg normalizer.
This commit is contained in:
@@ -11,10 +11,4 @@ describe('normalizeTerminalTextInput', () => {
|
||||
it('keeps ASCII hyphens unchanged', () => {
|
||||
expect(normalizeTerminalTextInput('git checkout -- file')).toBe('git checkout -- file')
|
||||
})
|
||||
|
||||
it('preserves longer trailing hyphen runs when iOS re-collapses the controlled value', () => {
|
||||
expect(normalizeTerminalTextInput('—', '--')).toBe('---')
|
||||
expect(normalizeTerminalTextInput('—', '---')).toBe('----')
|
||||
expect(normalizeTerminalTextInput('git checkout —', 'git checkout --')).toBe('git checkout ---')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,18 +1,9 @@
|
||||
// Why: iOS smart punctuation can rewrite two ASCII hyphens into a single
|
||||
// Unicode dash before React Native delivers terminal text input.
|
||||
// Unicode dash before React Native delivers terminal text input. Each dash maps
|
||||
// to exactly "--": recovering longer runs (#5222) needed the previous controlled
|
||||
// value written back into the field, and that write-back kills iOS dictation (#7925).
|
||||
const IOS_SMART_DASH_REPLACEMENT_PATTERN = /[\u2013\u2014]/g
|
||||
const IOS_SMART_DASH_REPLACEMENT_TEST = /[\u2013\u2014]/
|
||||
|
||||
export function normalizeTerminalTextInput(text: string, previousText = ''): string {
|
||||
const normalizedText = text.replace(IOS_SMART_DASH_REPLACEMENT_PATTERN, '--')
|
||||
const previousTrailingHyphens = /-+$/.exec(previousText)?.[0] ?? ''
|
||||
const previousPrefix = previousText.slice(0, previousText.length - previousTrailingHyphens.length)
|
||||
const collapsedPreviousHyphenRun =
|
||||
previousTrailingHyphens.length >= 2 &&
|
||||
IOS_SMART_DASH_REPLACEMENT_TEST.test(text) &&
|
||||
(text === `${previousPrefix}\u2013` || text === `${previousPrefix}\u2014`)
|
||||
if (collapsedPreviousHyphenRun) {
|
||||
return `${previousText}-`
|
||||
}
|
||||
return normalizedText
|
||||
export function normalizeTerminalTextInput(text: string): string {
|
||||
return text.replace(IOS_SMART_DASH_REPLACEMENT_PATTERN, '--')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user