Powershell: ConciseView formatting is broken when script body is indented with tabs

Created on 18 Dec 2019  路  5Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

Use tabs for indentation inside script body.

Expected behavior

Indentation with spaces:

image

Actual behavior

Indentation with tabs:

image

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.0-preview.6
PSEdition                      Core
GitCommitId                    7.0.0-preview.6-65-gab6b41dce31b2a9ce0f31357109059388da03e78
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Issue-Question Resolution-Fixed

Most helpful comment

I think for the purposes of the ErrorView itself, it doesn't matter if it reflects the _editor_ settings. The error should still be clear, as long as the number of spaces it turns a tab into matches what the position marker is coded to expect.

All 5 comments

So... I expect the first question they will ask is "well how many spaces do YOU think a tab should occupy?" And the problem is that not everyone will agree. I think it is likely that a significant majority of PowerShell users would prefer 4, not 8, but I doubt PowerShell is actually getting involved here, and it's left to the terminal to decide how big a tab is. I don't know if there is a way to configure that on conhost... maybe you could check on microsoft/terminal and let us know.

I doubt PowerShell is actually getting involved here

I take that back. PowerShell did decide where to put the ^ this is where the error occurred marker, so it did make a judgement call about how big a tab is. And it should apply that same judgement in the output by translating the tabs to however many spaces it used when deciding where to put the marker, to prevent different console settings from messing things up.

I guess that PS should translate tabs into spaces or keep tabs if that's feasible. In VSCode the default tab size is 4, however on ISE and Notepad it's 8 spaces (if I'm not mistaken).

I think for the purposes of the ErrorView itself, it doesn't matter if it reflects the _editor_ settings. The error should still be clear, as long as the number of spaces it turns a tab into matches what the position marker is coded to expect.

:tada:This issue was addressed in #11398, which has now been successfully released as v7.0.0-rc.2.:tada:

Handy links:

Was this page helpful?
0 / 5 - 0 ratings