diff --git a/CHANGELOG.md b/CHANGELOG.md index 58332d2..6c61f75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## Unreleased + +### Changed + +- The `Show-PesterResult` List panel now the files using relative path from the + current directory. It also added padding on the selected item as well as an + additional icon to show the highlight. + +### Fixed + +- Removed extra item from the stack that tracked which layer of the view you + were in. + + ## [0.1.0] Initial Version ### Added diff --git a/PesterExplorer/Private/Get-ListPanel.ps1 b/PesterExplorer/Private/Get-ListPanel.ps1 index 59e6868..91b0581 100644 --- a/PesterExplorer/Private/Get-ListPanel.ps1 +++ b/PesterExplorer/Private/Get-ListPanel.ps1 @@ -6,12 +6,40 @@ function Get-ListPanel { [string] $SelectedItem ) - $resultList = $List | ForEach-Object { + $unselectedStyle = @{ + RootColor = [Spectre.Console.Color]::Grey + SeparatorColor = [Spectre.Console.Color]::Grey + StemColor = [Spectre.Console.Color]::Grey + LeafColor = [Spectre.Console.Color]::White + } + $results = $List | ForEach-Object { $name = $_ - if ($name -eq $SelectedItem) { - $name = "[Turquoise2]$($name)[/]" + if($name -eq '..') { + # This is a parent item, so we show it as a folder + if ($name -eq $SelectedItem) { + Write-SpectreHost ":up_arrow: [Turquoise2]$name[/]" -PassThru | Format-SpectrePadded -Padding 1 + } else { + Write-SpectreHost "$name" -PassThru | Format-SpectrePadded -Padding 0 + } + } + elseif(Test-Path $name){ + $relativePath = [System.IO.Path]::GetRelativePath( + (Get-Location).Path, + $name + ) + if ($name -eq $SelectedItem) { + Format-SpectreTextPath -Path $relativePath | Format-SpectrePadded -Padding 1 + } else { + Format-SpectreTextPath -Path $relativePath -PathStyle $unselectedStyle | Format-SpectrePadded -Padding 0 + } + } + else { + if ($name -eq $SelectedItem) { + Write-SpectreHost ":right_arrow: [Turquoise2]$name[/]" -PassThru | Format-SpectrePadded -Padding 1 + } else { + Write-SpectreHost $name -PassThru | Format-SpectrePadded -Padding 0 + } } - return $name } - return $resultList | Format-SpectreRows | Format-SpectrePanel -Header "[white]List[/]" -Expand + $results | Format-SpectreRows | Format-SpectrePanel -Header "[white]List[/]" -Expand } diff --git a/PesterExplorer/Public/Show-PesterResult.ps1 b/PesterExplorer/Public/Show-PesterResult.ps1 index 29b0bae..c804f34 100644 --- a/PesterExplorer/Public/Show-PesterResult.ps1 +++ b/PesterExplorer/Public/Show-PesterResult.ps1 @@ -76,7 +76,6 @@ function Show-PesterResult { $selectedItem = $list[0] $stack = [System.Collections.Stack]::new() $object = $PesterResult - $stack.Push($object) #endregion Initial State while ($true) { @@ -90,17 +89,19 @@ function Show-PesterResult { $selectedItem = $list[($list.IndexOf($selectedItem) - 1 + $list.Count) % $list.Count] } elseif ($lastKeyPressed.Key -eq "Enter") { <# Recurse into Pester Object #> - if($items.Item($selectedItem).GetType().Name -eq "Test") { - # This is a test. We don't want to go deeper. - } if($selectedItem -like '*..*') { # Move up one via selecting .. $object = $stack.Pop() Write-Debug "Popped item from stack: $($object.Name)" } else { Write-Debug "Pushing item into stack: $($items.Item($selectedItem).Name)" + $stack.Push($object) $object = $items.Item($selectedItem) + if($object.GetType().Name -eq "Test") { + # This is a test. We don't want to go deeper. + $object = $stack.Pop() + } } $items = Get-ListFromObject -Object $object $list = [array]$items.Keys