terminal: Clear shell after activating (#39798)
Two tweaks were required to ensure we correctly clear the shell after running an activate script(s): 1. PowerShell upon receiving `\r\n` input, will enter the continuation mode (>>). To avoid this, we send an "enter" key press instead `\x0d`. 2. In order to clear the terminal _after_ issuing all activation commands, we need to take into account the asynchronous nature of the activation process: - We write the command to run the script to PTY - We send "enter" (It is now being processed by the shell) At this point we need to wait for the shell to finish executing before we clear the terminal. Otherwise we will create a race where we might clear the terminal _before_ the shell finished executing the activation script(s). - Write `clear`/`cls` command to PTY - Send "enter" This way we guarantee that we clear the terminal _after_ all scripts were executed. Closes #38474 Release Notes: - N/A
This commit is contained in:
@@ -389,4 +389,11 @@ impl ShellKind {
|
||||
ShellKind::Posix | ShellKind::Rc => "source",
|
||||
}
|
||||
}
|
||||
|
||||
pub const fn clear_screen_command(&self) -> &'static str {
|
||||
match self {
|
||||
ShellKind::Cmd => "cls",
|
||||
_ => "clear",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user