GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Nov 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Change is not breaking
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge and is not Work in Progress.
    • If the PR is work in progress, please add the prefix WIP: to the beginning of the title and remove the prefix when the PR is ready.
  • User-facing changes
    • Not Applicable
    • OR
    • User-facing Documentation needed
      • Issue filed - Issue link:
  • Testing - New and feature
    • Not Applicable or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed
      • Add [feature] if the change is significant or affects feature tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@SteveL-MSFT Steve Lee (SteveL-MSFT) assigned Ilya (iSazonov) Nov 13, 2018
@SteveL-MSFT
Steve Lee (SteveL-MSFT) requested review from Andrew (anmenaga) and Ilya (iSazonov) November 13, 2018 03:54
@SteveL-MSFT
[feature]
49f7c17
remove extra whitespace that is unnecessary and results in double newlines
@SteveL-MSFT
Steve Lee (SteveL-MSFT) force-pushed the format-whitespace branch from ffbfe0a to 49f7c17 Compare November 13, 2018 03:54
@iSazonov

Ilya (iSazonov) commented Nov 13, 2018

Copy link
Copy Markdown
Collaborator

What we get with:

dir | Format-Table -GroupBy Name
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Nov 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author
(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
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Nov 13, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author
(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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov

Ilya (iSazonov) commented Nov 13, 2018

Copy link
Copy Markdown
Collaborator

Is it ok to have one '\n' before "Directory ..."?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SteveL-MSFT

Steve Lee (SteveL-MSFT) commented Nov 13, 2018

Copy link
Copy Markdown
Member Author

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
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

iSazonov
Ilya (iSazonov) approved these changes Nov 13, 2018
View reviewed changes
anmenaga
Andrew (anmenaga) approved these changes Nov 13, 2018
View reviewed changes
Comment thread test/powershell/Language/Classes/Scripting.Classes.Attributes.Tests.ps1
Test-ValidateSet 'Hello' | Should -BeExactly 'Hello'
} finally {
Remove-Module -Name $moduleFile -Force
Remove-Module -Name $moduleFile -Force -ErrorAction SilentlyContinue

@anmenaga Andrew (anmenaga) Nov 13, 2018

Copy link
Copy Markdown

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.

All reactions

@SteveL-MSFT Steve Lee (SteveL-MSFT) Nov 13, 2018

Copy link
Copy Markdown
Member Author

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.

All reactions
@iSazonov
Ilya (iSazonov) merged commit 43e0394 into PowerShell:master Nov 14, 2018
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the format-whitespace branch November 14, 2018 06:50
@adityapatwardhan Aditya Patwardhan (adityapatwardhan) added the CL-Engine Indicates that a PR should be marked as an engine change in the Change Log label Nov 15, 2018
@adityapatwardhan

Aditya Patwardhan (adityapatwardhan) commented Nov 15, 2018

Copy link
Copy Markdown
Member

Ilya (@iSazonov) Reminder to add CL-XXX labels.

iSazonov reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iSazonov Ilya (iSazonov) mentioned this pull request Dec 28, 2018
while help an alias with *ending,like help dir* or help ls*,the output is in confusion #8541
Closed
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
@SteveL-MSFT @iSazonov
Remove extra newlines from formatting which resulted in necessary dou…
23a9db0
…ble newlines (PowerShell#8247)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@iSazonov Ilya (iSazonov) iSazonov approved these changes
+1 more reviewer
@anmenaga Andrew (anmenaga) anmenaga approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@iSazonov Ilya (iSazonov)

Labels

CL-Engine Indicates that a PR should be marked as an engine change in the Change Log

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Remove unnecessary newlines from output

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@SteveL-MSFT @iSazonov @adityapatwardhan @anmenaga
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.