From 4a1e11f1f310abb73b9e46fbb94f3c7b515e563f Mon Sep 17 00:00:00 2001 From: Michael Kelley Date: Sat, 19 Oct 2024 15:50:05 -0700 Subject: [PATCH] Add directory separator to end of completed path - Allows a more continuous tab completion experience --- PSFzf.TabExpansion.ps1 | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/PSFzf.TabExpansion.ps1 b/PSFzf.TabExpansion.ps1 index a95d9cf..2a46d6f 100644 --- a/PSFzf.TabExpansion.ps1 +++ b/PSFzf.TabExpansion.ps1 @@ -321,23 +321,21 @@ function script:Invoke-FzfTabCompletionInner() { $str = FixCompletionResult $result } - if ($script:continueCompletion) { - $isQuoted = $str.EndsWith("'") - $resultTrimmed = $str.Trim(@('''', '"')) - if (Test-Path "$resultTrimmed" -PathType Container) { - if ($isQuoted) { - $str = "'{0}{1}'" -f "$resultTrimmed", $script:TabContinuousTrigger - } - else { - $str = "$resultTrimmed" + $script:TabContinuousTrigger - } + $isQuoted = $str.EndsWith("'") + $resultTrimmed = $str.Trim(@('''', '"')) + if (Test-Path "$resultTrimmed" -PathType Container) { + if ($isQuoted) { + $str = "'{0}{1}'" -f "$resultTrimmed", $script:TabContinuousTrigger } else { - # no more paths to complete, so let's stop completion: - $str += ' ' - $script:continueCompletion = $false + $str = "$resultTrimmed" + $script:TabContinuousTrigger } } + else { + # no more paths to complete, so let's stop completion: + $str += ' ' + $script:continueCompletion = $false + } $leftCursor = $completions.ReplacementIndex $replacementLength = $completions.ReplacementLength