Skip to content

Commit

Permalink
Add directory separator to end of completed path
Browse files Browse the repository at this point in the history
- Allows a more continuous tab completion experience
  • Loading branch information
kelleyma49 committed Oct 19, 2024
1 parent 765dd69 commit 4a1e11f
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions PSFzf.TabExpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4a1e11f

Please sign in to comment.