Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSReadLine Prompt not showing up after F8 in SSH Remoting #2605

Open
PowerCoder opened this issue Apr 2, 2020 · 12 comments
Open

PSReadLine Prompt not showing up after F8 in SSH Remoting #2605

PowerCoder opened this issue Apr 2, 2020 · 12 comments
Labels

Comments

@PowerCoder
Copy link

PowerCoder commented Apr 2, 2020

I don't know if this is actually supported by the devs at this point, since the whole SSH-thing is still new on Windows. So I'm asking here. If it is valid for a bug report, please tell me the info you need, since it concerns VSCode, PowerShell 7 across 2 systems.

I enabled PSRemoting from my Windows to my Linux box. Since it has no GUI, I figured I should do an Enter-PSSession in the VSCode terminal, then develop my code from VSCode.

There is some unexpected behavior. First, a cosmetics issue. Tab completion on filesystem paths will always show a backslash instead of a forward slash. So I type /tm, press TAB and it turns into /tmp\. This does not happen if I first SSH to the Linux box and then start pwsh from its local shell. It is no problem, since it will automatically turn into a forward slash if I TAB-complete the next level.

More importantly, if I select a line in VSCode and press F8 to execute it, two things happen. First, if there is no output, the line will be copied to the terminal but not executed. I need to manually press Enter in the terminal window in order to actually execute the code. This also happens on the last line of a multi-line block and with both settings of the focusonexecute setting. Windows/Unix line feed differences?

@ghost ghost added the Needs: Triage Maintainer attention needed! label Apr 2, 2020
@PowerCoder
Copy link
Author

PowerCoder commented Apr 2, 2020

To add, if there is output, it will execute successfully.

So:
$Var = 1 + 2 followed by F8
Gives me:
PS>$Var = 1 + 2 with a cursor under the $ waiting for me to press Enter.
But once it has been executed once, if I do F8 on the variable I get:
PS>$Var with a 3 under the $

Which is another cosmetics thing, the first line of the output will get indented up to the prompt.

@SydneyhSmith
Copy link
Collaborator

@PowerCoder have you been able to successfully try the tab completion behavior outside of VSCode, or does this issue just appear when you are in VSCode?

@SydneyhSmith SydneyhSmith added Needs-Repro-Info and removed Needs: Triage Maintainer attention needed! labels Apr 2, 2020
@PowerCoder
Copy link
Author

PowerCoder commented Apr 2, 2020

If I start PS7 on Windows, then use the Windows SSH client to go to the Linux box, start pwsh, tab completion will go correctly.

If I start PS7 on Windows, then issue Enter-PSSession to go directly into the Linux PS shell, tab completion will append a backslash instead of a forward slash at the ends of every directory.

My guess is that because the parent-session/host is a Windows PS, it will default to Windows-style (backslashes). Compatibility will then auto-correct them to forward slashes upon execution or further path traversal.

This behavior is identical in both a standard PowerShell 7 host and the VSCode terminal host. Which means that particular issue likely belongs in the main PwSh repo.

Thanks for helping me figure that one out.

If I SSH first, then start pwsh, using F8 will postpone execution until I've exited the SSH session. This is likely works as designed, it being a shell within a shell and all.

The "breaking" issue remains though.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 2, 2020
@PowerCoder
Copy link
Author

PowerCoder commented Apr 2, 2020

Another addition, I can queue commands up this way as well, since they don't execute until I press Enter.

$Var1 = 1 + 2 followed by F8
Terminal displays:
PS>$Var = 1 + 2 with a cursor under the $

Then, $Var2 = 2 + 3 followed by F8
Terminal displays:
PS>$Var = 1 + 2 with $Var2 = 2 + 3 indented exactly under the first one, cursor now under the new line.
If I then press Enter in the Terminal window, both lines are executed. And Var1 & Var2 are stored.

@PowerCoder
Copy link
Author

PowerCoder commented Apr 3, 2020

When I did an Invoke-Webrequest and stored the output in a variable (thus having no output), I saw a progress bar flash by. So apparently the command does get executed, but after execution the terminal host does not return to the prompt until I press Enter.

I can probably test that with an Out-File/Add-Content. I'll try tomorrow.

@TylerLeonhardt
Copy link
Member

@PowerCoder can you please open an issue over in https://github.com/PowerShell/PowerShell about:

If I start PS7 on Windows, then issue Enter-PSSession to go directly into the Linux PS shell, tab completion will append a backslash instead of a forward slash at the ends of every directory.

My guess is that because the parent-session/host is a Windows PS, it will default to Windows-style (backslashes). Compatibility will then auto-correct them to forward slashes upon execution or further path traversal.

This behavior is identical in both a standard PowerShell 7 host and the VSCode terminal host. Which means that particular issue likely belongs in the main PwSh repo.

This behavior like you said is by design because you've executed ssh first.

If I SSH first, then start pwsh, using F8 will postpone execution until I've exited the SSH session. This is likely works as designed, it being a shell within a shell and all.

Enter-PSSession will work with F8 but calling ssh directly won't.

@PowerCoder
Copy link
Author

PowerCoder commented Apr 3, 2020

Done and Done: Issue 12253

Thank you. Hope the second issue can now get a new tag though, having to constantly click in the terminal and press Enter before going back to my code gets old fast.

Which reminds me:
"Hello, World!" | Out-File -LiteralPath '/tmp/Hello-World.txt' followed by F8 results in:

[linuxbox.localdomain]: PS /root> "Hello, World!" | Out-File -LiteralPath '/tmp/Hello-World.txt' with a cursor waiting for me to press Enter.

If I check from a separate SSH session without pressing Enter:

root@linuxbox ~ # ls -l /tmp | grep Hello
-rw-r--r-- 1 root root 14 Apr  3 20:42 Hello-World.txt

In other words, the command is executed, but the terminal doesn't drop back to a prompt until I press Enter in it.

So what would happen if I F8 on a line that stores a variable, then on a line that presents the value of that variable as output?
$Var1 = 'Hello, World!' followed by F8 results in:

[linuxbox.localdomain]: PS /root> $Var1 = 'Hello, World!'
                                  D

where the D represents the cursor, waiting for me to press Enter.

Without doing so, I go to the second line:
$Var1 followed by F8, which results in:

[linuxbox.localdomain]: PS /root> $Var1 = 'Hello, World!'
                                  $Var1
                                  Hello, World!
[linuxbox.localdomain]: PS /root>

Which confirms my earlier statement that I am not returned to a prompt when there is no output, but I am returned to a prompt when there IS output.

And finally, what happens if I press something other than Enter while it waits?

[linuxbox.localdomain]: PS /root> $Var1 = 'Hello, World!'
                                  hhhjhjhjhjhj

hhhjhjhjhjhj: The term 'hhhjhjhjhjhj' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
[linuxbox.localdomain]: PS /root>

That's about all the tests I can think of.

@SydneyhSmith
Copy link
Collaborator

@PowerCoder thanks for the detailed description, unfortunately I think we are still having some trouble understanding the problem, could you please provide a GIF or video of the behavior...thanks!

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Apr 7, 2020
@PowerCoder
Copy link
Author

I'll see if I can find something suitable to record and upload. In the meantime, I'll make another attempt.

Given this statement:
$Variable = 1 + 2

Expected behavior is when I execute it using F8, it pastes it into the Terminal window, executes it and returns to the prompt.

Current behavior is when I execute it using F8, it pastes it into the Terminal window, executes it but doesn't return to the prompt. Instead, the cursor waits patiently in the Terminal window for me to press Enter before returning to the prompt.

The conditions for me to reproduce it are:

  1. Use Enter-PSSession to enter into the Linux box.
  2. Execute a statement that provides no output.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Apr 9, 2020
@SydneyhSmith
Copy link
Collaborator

@PowerCoder thanks, that clarifies the behavior for us

@SydneyhSmith SydneyhSmith changed the title Is this in scope? PSReadLine Prompt not showing up after F8 in SSH Remoting Apr 9, 2020
@SydneyhSmith SydneyhSmith added Area-PSReadLine Issue-Bug A bug to squash. and removed Needs-Repro-Info Needs: Maintainer Attention Maintainer attention needed! labels Apr 9, 2020
@SydneyhSmith
Copy link
Collaborator

You may also want to give this extension a try:
https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh

@andyleejordan
Copy link
Member

@SeeminglyScience might want to take a look at this? Probably fixed with your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants