fix(cli): do not fail on invalid terminal width

resolves #2253
This commit is contained in:
Jan De Dobbeleer 2022-05-11 18:52:20 +02:00 committed by Jan De Dobbeleer
parent bf7bca4764
commit 6a7f03eb5b

View file

@ -281,6 +281,10 @@ Example:
Set-PoshContext Set-PoshContext
$terminalWidth = $Host.UI.RawUI.WindowSize.Width $terminalWidth = $Host.UI.RawUI.WindowSize.Width
# set a sane default when the value can't be retrieved
if (-not $terminalWidth) {
$terminalWidth = 0
}
$standardOut = @(Start-Utf8Process $script:OMPExecutable @("print", "primary", "--error=$script:ErrorCode", "--pwd=$cleanPWD", "--pswd=$cleanPSWD", "--execution-time=$script:ExecutionTime", "--stack-count=$stackCount", "--config=$env:POSH_THEME", "--shell-version=$script:PSVersion", "--terminal-width=$terminalWidth", "--shell=::SHELL::")) $standardOut = @(Start-Utf8Process $script:OMPExecutable @("print", "primary", "--error=$script:ErrorCode", "--pwd=$cleanPWD", "--pswd=$cleanPSWD", "--execution-time=$script:ExecutionTime", "--stack-count=$stackCount", "--config=$env:POSH_THEME", "--shell-version=$script:PSVersion", "--terminal-width=$terminalWidth", "--shell=::SHELL::"))
# make sure PSReadLine knows we have a multiline prompt # make sure PSReadLine knows we have a multiline prompt
$extraLines = ($standardOut | Measure-Object -Line).Lines - 1 $extraLines = ($standardOut | Measure-Object -Line).Lines - 1