microsoft / node-pty

Fork pseudoterminals in Node.JS
Other
1.43k stars 232 forks source link

note-pty is sending data to Xterm at wrong timing before \x1b[K when "clear" is entered on powershell. #543

Closed plcs2eco closed 2 years ago

plcs2eco commented 2 years ago

Environment details

Here is the capture of the incorrect sequence. nodepty_clear

is there any way to fix this on my side? If anyone could help me, I would appreciate it.

The below picture is "cd" was entered and it brought up the CWD at the second line after "clear" deleted all screen including CWD. image

plcs2eco commented 2 years ago

I am capturing those data as the blow code. The first console.log is omitting the first character. Because when it included \x1b, the color of the characters displayed on the ocnsole is yellowish very white and very difficult read. But the second console.log is outputting ASCII code in hex. so I can see \x1b as 1b. So I am capturing whatever ptyProcess.onData is sending from main.js. -------------------in renderer.js--------------------------------------- window.myApi.on is ipcRendere.on(channel, args) defined in preloader.js.

window.myApi.on("terminal.incomingData", (event, data) => { term.write(data); console.log(data.substring(1,data.length)); let b=""; for (let i = 0; i < data.length; i++) { b += data.charCodeAt(i).toString(16)+" "; } console.log(b); });

-------------main.js----------------- ptyProcess.onData(data => { mainWindow.webContents.send("terminal.incomingData", data); });

Tyriar commented 2 years ago

The cd on the separate line may be because your xterm instance size got out of sync with your pty? The form of the sequences coming back is actually out of the control of this package and it's related to conpty which is built-in to Windows. Windows Terminal bundles a newer version of conpty so bugs may be fixed there that you see in your usage.

plcs2eco commented 2 years ago

Hi Tyriar, Thank you very much for clarifying me that Node-pty is just sending the form of the sequences from conpty. I will wait to get the newer version of conpty then.

By the way, the cd on the second line is displaying correctly. It looks the line of the cd is separated because conpty returned incorrect sequence and wiped out all screen including current working directory with ">" after "clear" command. So the screen was all back when "cd" was entered. Then when ENT is pressed after the cd, it changed to the below line and conpty sent the correct strings "PS C:Users_ >. So it is all good. As you clarified me, I just have to wait to get the newer version of conpty from Microsoft though I still figure out how to get it.