Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9bcc6fc

Browse files
committed
Revert "fix: normalize lf enter in tui input"
This reverts commit c1f9b3e.
1 parent c1f9b3e commit 9bcc6fc

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

src/ink/parse-keypress.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,6 @@ function inputToString(input: Buffer | string): string {
210210
}
211211
}
212212

213-
function splitTextToken(value: string): string[] {
214-
return value.match(/\r\n|[\r\n]|[^\r\n]+/g) ?? []
215-
}
216-
217213
export function parseMultipleKeypresses(
218214
prevState: KeyParseState,
219215
input: Buffer | string | null = '',
@@ -282,9 +278,7 @@ export function parseMultipleKeypresses(
282278
const mouse = parseMouseEvent(resynthesized)
283279
keys.push(mouse ?? parseKeypress(resynthesized))
284280
} else {
285-
for (const chunk of splitTextToken(token.value)) {
286-
keys.push(parseKeypress(chunk))
287-
}
281+
keys.push(parseKeypress(token.value))
288282
}
289283
}
290284
}
@@ -704,9 +698,11 @@ function parseKeypress(s: string = ''): ParsedKey {
704698
return createNavKey(s, 'mouse', false)
705699
}
706700

707-
if (s === '\r' || s === '\n' || s === '\r\n') {
701+
if (s === '\r') {
708702
key.raw = undefined
709703
key.name = 'return'
704+
} else if (s === '\n') {
705+
key.name = 'enter'
710706
} else if (s === '\t') {
711707
key.name = 'tab'
712708
} else if (s === '\b' || s === '\x1b\b') {

0 commit comments

Comments
 (0)