You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Windows standard line endings are CRLF. In our PowerShell host, we make sure each \n is converted to a \r\n to conform to the standard, but PSReadLine expects only \n. When we pass \r\n, it prints ^M.
PSReadLine should conform to the Windows standard. Is it possible to make this change?
Jason, this is the PowerShell Studio console, but it should repro on any host that interprets \n as \r\n, per the Windows standard.
To repro in PowerShell Studio:
I think PSReadline is doing the correct thing here, and the PowerShell Studio host is incorrectly sending \r as a keystroke.
For comparison, conhost does not send that key when pasting via right click. Similarly, if you paste via Ctrl+v, PSReadline does the right thing here.
That said, it looks like PowerShell Studio is redirecting standard input. That causes lots of problems because there is no terminal emulation support, so many key binding don't work. When PSReadline sees redirected input, I think I'll be forced to deal with emulating what conhost does in terms of ignoring \r.
If I'm wrong about how PowerShell Studio is implemented, then I think PowerShell Studio needs to be changed because it would be acting more like conhost in that case.
I just checked and we don't redirect anything. We use standard Microsoft APIs to attach a console to a Windows host (AttachConsole) and write to the console (WriteConsole). WriteConsole requires CRLF, so we use it. It seems to me that PSReadline should support this.
Activity
lzybkr commentedon Jun 16, 2015
How do I reproduce this issue?
juneb commentedon Jun 22, 2015
Jason, this is the PowerShell Studio console, but it should repro on any host that interprets \n as \r\n, per the Windows standard.
To repro in PowerShell Studio:
lzybkr commentedon Jun 22, 2015
I think PSReadline is doing the correct thing here, and the PowerShell Studio host is incorrectly sending \r as a keystroke.
For comparison, conhost does not send that key when pasting via right click. Similarly, if you paste via Ctrl+v, PSReadline does the right thing here.
That said, it looks like PowerShell Studio is redirecting standard input. That causes lots of problems because there is no terminal emulation support, so many key binding don't work. When PSReadline sees redirected input, I think I'll be forced to deal with emulating what conhost does in terms of ignoring \r.
If I'm wrong about how PowerShell Studio is implemented, then I think PowerShell Studio needs to be changed because it would be acting more like conhost in that case.
juneb commentedon Jun 23, 2015
Thanks for the quick reply, Jason. I'll pass on the info.
juneb commentedon Jun 23, 2015
I just checked and we don't redirect anything. We use standard Microsoft APIs to attach a console to a Windows host (AttachConsole) and write to the console (WriteConsole). WriteConsole requires CRLF, so we use it. It seems to me that PSReadline should support this.
lzybkr commentedon Nov 11, 2017
Closing in favor of #579 which covers all of the known issues with right-click paste.