From 8c1c74a5d135364f7d5a8864343c17937c0f1946 Mon Sep 17 00:00:00 2001 From: Keith Dahlby Date: Wed, 11 Jul 2018 23:40:20 -0500 Subject: [PATCH] Add better WindowTitle debug messages --- src/WindowTitle.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/WindowTitle.ps1 b/src/WindowTitle.ps1 index 388a6f7e5..9fbc00733 100644 --- a/src/WindowTitle.ps1 +++ b/src/WindowTitle.ps1 @@ -10,11 +10,13 @@ function Test-WindowTitleIsWriteable { $Host.UI.RawUI.WindowTitle = $newTitle $script:HostSupportsSettingWindowTitle = ($Host.UI.RawUI.WindowTitle -eq $newTitle) $Host.UI.RawUI.WindowTitle = $OriginalWindowTitle + Write-Debug "HostSupportsSettingWindowTitle: $HostSupportsSettingWindowTitle" + Write-Debug "OriginalWindowTitle: $OriginalWindowTitle" } catch { $script:OriginalWindowTitle = $null $script:HostSupportsSettingWindowTitle = $false - Write-Debug "Probing for HostSupportsSettingWindowTitle errored: $_" + Write-Debug "HostSupportsSettingWindowTitle error: $_" } } return $HostSupportsSettingWindowTitle @@ -27,6 +29,7 @@ function Reset-WindowTitle { # Revert to original WindowTitle, but only if posh-git is currently configured to set it if ($HostSupportsSettingWindowTitle -and $OriginalWindowTitle -and $settings.WindowTitle) { + Write-Debug "Resetting WindowTitle: '$OriginalWindowTitle'" $Host.UI.RawUI.WindowTitle = $OriginalWindowTitle } } @@ -40,13 +43,14 @@ function Set-WindowTitle { if ($settings.WindowTitle -and (Test-WindowTitleIsWriteable)) { try { if ($settings.WindowTitle -is [scriptblock]) { - $windowTitleText = & $settings.WindowTitle $GitStatus $IsAdmin + # ensure results returned by scriptblock are flattened into a string + $windowTitleText = "$(& $settings.WindowTitle $GitStatus $IsAdmin)" } else { $windowTitleText = $ExecutionContext.SessionState.InvokeCommand.ExpandString("$($settings.WindowTitle)") } - # Put $windowTitleText in a string to ensure results returned by scriptblock are flattened into a string + Write-Debug "Setting WindowTitle: $windowTitleText" $Host.UI.RawUI.WindowTitle = "$windowTitleText" } catch {