Closed jhmaster2000 closed 10 months ago
What I experience here is that some keys get typed double. This appear similar to:
Update with Canary after #3099 was fixed. In step 7 it still breaks for me, because it seems like Tab
is clicked twice even though I'm sure I only click it one. The result is that w
"Tab+Tab" gives:
> worldLine: world
> Exiting...
So I can't get beyond step 7 due to this.
@dylan-conway , after looking at the clack issue, do you have any idea why "Tab" might be executed twice?
The issue with double letters met when writing "sample text" and the issue with Ctrl+D to exit appear to have been resolved
@dylan-conway , after looking at the clack issue, do you have any idea why "Tab" might be executed twice?
I'm not sure yet, I tried to fix this yesterday but failed. I'll try again today. Seems to be related to the readline exit event
On current 0.8.2 canary on Linux all the issues are resolved for me, except for completions which hitting Tab makes the entire stdin freeze and become completely unresponsive.
Without a completer
function specified Tab behaves normally, so at least readline is now usable without completions.
Seems to relate to my issue as well: #4835
In Bun v1.0.7, it appears to exit after you get to the w
step and press Tab
.
❯ bun rl.ts
> test history 3
Line: test history 3
> sample text
Line: sample text
> sample text
Line: sample text
> hello
Line: hello
> worldLine: world
> Exiting...
Yep, can reproduce, to put it in general terms, it seems to succeed at a first completion and then crashes on a second one, likely something not being properly cleaned up/freed for re-use in the completion handling code.
👀 i think i fixed this
What version of Bun is running?
0.6.3
What platform is your computer?
Linux 5.15.90.1-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
There are multiple issues with the
readline
polyfill at the moment, given the following sample filetest.ts
:Ran on Bun with:
bun run test.ts
Ran on Node.js for comparison with:ts-node-esm test.ts
(npm i -g ts-node
)What is the expected behavior?
Running the file in Node.js as indicated above and performing the following sequence of inputs:
Arrow Up
3 times (it should cycle through the preset history fromtest history 1
totest history 3
on the prompt)Enter
(it should printLine: test history 3
)Enter
(it should printLine: sample text
)Arrow Up
(it should showsample text
from the updated history)Arrow Down
(it should go back to the blank prompt)h
and pressTab
(it should auto-complete tohello
) then pressEnter
(it should printLine: hello
)w
and pressTab
(it should auto-complete toworld
) then pressTab
again (it should list matching completions)Enter
(it should printLine: world
)Tab
twice (it should print all completionshello world
Ctrl + D
to exit (It should printExiting...
and then terminate the program)Resulting in the below final output:
What do you see instead?
Running the same file in Bun following the same inputs as above:
Results in the following output: (this output is outdated and no longer relevant)
Going over everything that went wrong here:
Striked out issues have been fixed.
Issue at steps 1, 2, 4, 5, 6:Has already been reported at #2035 so I will not focus on it, this issue is for the other issues not covered by the linked issue.Issue at steps 3 & 8:The input texts (sample text
andw
respectively) have been duplicated. This only occurs if an error has happened in the previous prompt.Issue at steps 7 & 9: (Remains in Bun 0.8.2)
Tab
simply enters an actual tab into the input, rather than triggering completions.Tab
Tab
character in the prompt, it sometimes triggers the error seen underLine: w
Issue at step 10:Ctrl + D
will make the program unresponsive to the terminal, but it will not terminate.Ctrl + C
is required to terminate.Exiting...
was not printed.rl.on("close")
was not called.Bonus IssueOn step 6, after pressingTab
but before pressingEnter
, hold downBackspace
You would expect to be able to wipe the line clean back to blank.Instead, the first character of the prompt (^
in this case) becomes undeletable.The character is a ghost character, since the'line'
event doesn't echo it back when pressingEnter
.This isn't necessarily always the first character of the prompt, more generally, backspace behaves weirdly after tabbing.Additional information
Updated for Bun v0.6.3 (issue persists)