From 297452d1338c42e71d3a4ca377a27526bb9c2ee4 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Tue, 27 May 2025 13:35:01 -0700 Subject: [PATCH 1/2] =?UTF-8?q?feat(Get-ListPanel):=20=E2=9C=A8=20enhance?= =?UTF-8?q?=20item=20display=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Improved the visual representation of items in the list. * Added handling for parent items and adjusted styles for selected/unselected items. * Refactored code for better readability and maintainability. --- PesterExplorer/Private/Get-ListPanel.ps1 | 38 ++++++++++++++++++--- PesterExplorer/Public/Show-PesterResult.ps1 | 10 +++--- 2 files changed, 39 insertions(+), 9 deletions(-) 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..a0f1114 100644 --- a/PesterExplorer/Public/Show-PesterResult.ps1 +++ b/PesterExplorer/Public/Show-PesterResult.ps1 @@ -76,7 +76,7 @@ function Show-PesterResult { $selectedItem = $list[0] $stack = [System.Collections.Stack]::new() $object = $PesterResult - $stack.Push($object) + #$stack.Push($object) #endregion Initial State while ($true) { @@ -90,17 +90,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 From 660ab2b8c368bb69018bd553a25ab6bcfc819f32 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Tue, 27 May 2025 13:40:41 -0700 Subject: [PATCH 2/2] =?UTF-8?q?chore(CHANGELOG):=20=E2=9C=8F=EF=B8=8F=20up?= =?UTF-8?q?date=20changelog=20for=20recent=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Documented changes to the `Show-PesterResult` List panel, including: * Use of relative paths from the current directory. * Added padding on the selected item and an additional highlight icon. * Fixed an issue by removing an extra item from the stack that tracked the view layer. --- CHANGELOG.md | 14 ++++++++++++++ PesterExplorer/Public/Show-PesterResult.ps1 | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) 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/Public/Show-PesterResult.ps1 b/PesterExplorer/Public/Show-PesterResult.ps1 index a0f1114..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) {