Skip to content

Commit c9d6459

Browse files
SteveL-MSFTdaxian-dbw
authored andcommitted
Add trailing line number to filename for ConciseView (#11391)
1 parent 6dde778 commit c9d6459

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,13 @@ function Get-ConciseViewPositionMessage {
10581058
$useTargetObject = $true
10591059
}
10601060
elseif ($myinv.ScriptName) {
1061-
$posmsg = ""${resetcolor}$($myinv.ScriptName)${newline}""
1061+
if ($env:TERM_PROGRAM -eq 'vscode') {
1062+
# If we are running in vscode, we know the file:line:col links are clickable so we use this format
1063+
$posmsg = ""${resetcolor}$($myinv.ScriptName):$($myinv.ScriptLineNumber):$($myinv.OffsetInLine)${newline}""
1064+
}
1065+
else {
1066+
$posmsg = ""${resetcolor}$($myinv.ScriptName):$($myinv.ScriptLineNumber)${newline}""
1067+
}
10621068
}
10631069
else {
10641070
$posmsg = ""${newline}""

test/powershell/engine/Formatting/ErrorView.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Describe 'Tests for $ErrorView' -Tag CI {
3232
$testScriptPath = Join-Path -Path $TestDrive -ChildPath 'test.ps1'
3333
Set-Content -Path $testScriptPath -Value $testScript
3434
$e = { & $testScriptPath } | Should -Throw -ErrorId 'UnexpectedToken' -PassThru
35-
$e | Out-String | Should -BeLike "*$testScriptPath*"
35+
$e | Out-String | Should -BeLike "*${testScriptPath}:4*"
3636
# validate line number is shown
3737
$e | Out-String | Should -BeLike '* 4 *'
3838
}

0 commit comments

Comments
 (0)