Skip to content

Commit

Permalink
Add directory separator to end of completed path (#282)
Browse files Browse the repository at this point in the history
- Allows a more continuous tab completion experience
  • Loading branch information
kelleyma49 authored Oct 19, 2024
1 parent 765dd69 commit ec306f6
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 ec306f6

Please sign in to comment.