Skip to content

Commit

Permalink
Try skipping set-consolemode on PSCore on Windows only for ConsoleHost
Browse files Browse the repository at this point in the history
I've seen that not using set-consolemode within VSCode/s PS integrated
console causes problems after executing git log --graph --decorate.
  • Loading branch information
rkeithhill committed Nov 3, 2018
1 parent 7fc0c92 commit 78ad465
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/ConsoleMode.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Hack! https://gist.github.com/lzybkr/f2059cb2ee8d0c13c65ab933b75e998c

if ($IsWindows -eq $false) {
# Always skip setting the console mode on non-Windows platforms.
# On Windows, *if* we are running in PowerShell Core *and* the host is the "ConsoleHost",
# rely on PS Core to manage the console mode. This speeds up module import on standard
# PowerShell Core on Windows.
if (($IsWindows -eq $false) -or (($PSVersionTable.PSVersion.Major -ge 6) -and ($host.Name -eq 'ConsoleHost'))) {
function Set-ConsoleMode {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
param()
Expand Down
2 changes: 1 addition & 1 deletion src/GitPrompt.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ function Global:Write-VcsStatus {
Set-ConsoleMode -ANSI

$OFS = ""
$sb = [System.Text.StringBuilder]::new(150)
$sb = [System.Text.StringBuilder]::new(256)

foreach ($promptStatus in $global:VcsPromptStatuses) {
[void]$sb.Append("$(& $promptStatus)")
Expand Down

0 comments on commit 78ad465

Please sign in to comment.