question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`Write-Host -NoNewLine` not respected

See original GitHub issue

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

I have written PowerShell module PSWriteColor which uses Write-Host -NoNewLine pretty much all the time

image

Write-Host -NoNewline -BackgroundColor Red -Object 'Test'
Write-Host -NoNewline -BackgroundColor Blue -Object 'Test 1'
Write-Host -NoNewline -BackgroundColor DarkGray -Object 'Test 2'

image

Write-Color -Text 'Test1 ', 'Test2 ','Test3' -Color Red, Blue, DarkGray

PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.22000.282
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22000.282
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Visual Studio Code Version

1.61.2
6cba118ac49a1b88332f312a8f67186f7f3c1643
x64

Extension Version

ironmansoftware.powershell-universal@2.3.0
ms-vscode.powershell@2021.10.2
ms-vscode.powershell-preview@2021.10.3
tobysmith568.run-in-powershell@1.1.1
TylerLeonhardt.vscode-inline-values-powershell@0.0.5

Steps to Reproduce

Type in powershell editor, press F5

Write-Host -NoNewline -BackgroundColor Red -Object 'Test'
Write-Host -NoNewline -BackgroundColor Blue -Object 'Test 1'
Write-Host -NoNewline -BackgroundColor DarkGray -Object 'Test 2'

Visuals

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
andschwacommented, Jan 18, 2022

Fix for this has been merged!

1reaction
andschwacommented, Nov 5, 2021

Ohh, I see! Thanks Patrick.

Read more comments on GitHub >

github_iconTop Results From Across the Web

write-host -NoNewline parameter is ignored with powershell 5.1
Starting with WMF 5.1 the -NoNewLine option for Write-Host is essentially ignored. Simple example: PS C:\> Write-Host "no newline test " - ...
Read more >
PS -nonewline not work on my console - Microsoft Learn
when I try cmdlet "write-host -nonewline" on my PS console as tutorial(windows10 Home, PS 5.1). PS C:\Windows\system32> write-host "no ...
Read more >
Understanding the PowerShell Write-Host Cmdlet
That's because the -NoNewLine parameter isn't really respected since that is mostly a host formatting tool. This may not be a big deal,...
Read more >
Is it possible to Write-host with no new line and overwrite the ...
I'm reading that it writes out the characters and then hits backspace which would make me think it always overwrites the last thing...
Read more >
Write-Host - PowerShell Command - PDQ
This command displays the input to the console, but because of the NoNewline parameter, the output is followed directly by the prompt. Write...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found