GeezerVison is showing github.com — Remove extra newlines from formatting which resulted in necessary double newlines by SteveL-MSFT · Pull Request #8247 · PowerShell/PowerShell
Conversation
PR Summary
When formatting, the Group start and end added unnecessary newlines which resulted in double newlines in many cases. Formatting changes are not considered breaking.
(get-module | out-string).replace("`n","\n`n")
Before:
\n
ModuleType Version Name ExportedCommands\n
---------- ------- ---- ----------------\n
Manifest 6.1.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty...}\n
Manifest 6.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}\n
Script 2.0.0 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler...}\n
\n
\n
After:
\n
ModuleType Version Name ExportedCommands\n
---------- ------- ---- ----------------\n
Manifest 6.1.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty...}\n
Manifest 6.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}\n
Script 2.0.0 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler...}\n
\n
There are still a few cases where the final output has two newlines (but not three anymore!). This is a bit more complicated to fix and would need to track state that either a newline was the last thing output or the item is the last in a collection and doesn't need a separator.
Fix #7186
PR Checklist
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
remove extra whitespace that is unnecessary and results in double newlines
|
What we get with:
dir | Format-Table -GroupBy Name
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
(get-process pwsh | format-list | Out-String).Replace("`n","\n`n")
Before:
\n
\n
Id : 1626\n
Handles : 0\n
CPU : 5697.7865177\n
SI : 422\n
Name : pwsh\n
\n
Id : 18927\n
Handles : 0\n
CPU : 480.0566228\n
SI : 18920\n
Name : pwsh\n
\n
Id : 18928\n
Handles : 0\n
CPU : 771.2722798\n
SI : 422\n
Name : pwsh\n
\n
\n
\n
After:
\n
Id : 1626\n
Handles : 0\n
CPU : 5696.2817117\n
SI : 422\n
Name : pwsh\n
\n
Id : 18927\n
Handles : 0\n
CPU : 474.75417\n
SI : 18920\n
Name : pwsh\n
\n
Id : 18928\n
Handles : 0\n
CPU : 769.8305049\n
SI : 422\n
Name : pwsh\n
\n
\n
|
rkeithhill reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
(dir | select -first 3 |Format-Table -GroupBy Name | out-string).replace("`n","\n`n")
Before:
\n
\n
Directory: /Users/steve/repos/PowerShell\n
\n
\n
Mode LastWriteTime Length Name\n
---- ------------- ------ ----\n
d----- 11/4/18 7:47 AM assets\n
\n
\n
Directory: /Users/steve/repos/PowerShell\n
\n
\n
Mode LastWriteTime Length Name\n
---- ------------- ------ ----\n
d----- 10/26/18 10:24 AM demos\n
\n
\n
Directory: /Users/steve/repos/PowerShell\n
\n
\n
Mode LastWriteTime Length Name\n
---- ------------- ------ ----\n
d----- 10/26/18 10:24 AM docker\n
\n
\n
After:
\n
\n
Directory: /Users/steve/repos/PowerShell\n
\n
Mode LastWriteTime Length Name\n
---- ------------- ------ ----\n
d----- 11/4/18 7:47 AM assets\n
\n
Directory: /Users/steve/repos/PowerShell\n
\n
Mode LastWriteTime Length Name\n
---- ------------- ------ ----\n
d----- 10/26/18 10:24 AM demos\n
\n
Directory: /Users/steve/repos/PowerShell\n
\n
Mode LastWriteTime Length Name\n
---- ------------- ------ ----\n
d----- 10/26/18 10:24 AM docker\n
\n
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Is it ok to have one '\n' before "Directory ..."?
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Ilya (@iSazonov) you are asking if it's ok to separate the groups with just a single newline vs two? Seems fine to me and just as readable visually. In the future, we should leverage vt100 as a way to provide visual indicators rather than rely on whitespace only.
|
iSazonov reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
Test-ValidateSet 'Hello' | Should -BeExactly 'Hello'
|
|
|
} finally {
|
|
|
Remove-Module -Name $moduleFile -Force
|
|
|
Remove-Module -Name $moduleFile -Force -ErrorAction SilentlyContinue
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not related to this formatting code change, right?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. Was running the tests locally and this line was outputting unncessarily
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
iSazonov reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Labels
CL-Engine
Indicates that a PR should be marked as an engine change in the Change Log
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|