kelleyma49 / PSFzf

A PowerShell wrapper around the fuzzy finder fzf
MIT License
750 stars 35 forks source link

Feature request: Adding trailing slash for directory when tab completion. #259

Open segln opened 4 months ago

segln commented 4 months ago

Please add a trailing slash option for directory when tab completion.

Example

cd C:\Us_

Pressing \<Tab>:

Current

cd C:\Users

Trailing slash

cd C:\Users\

Thank you for your consideration.

segln commented 4 months ago

I think it can be done with removing the conditional statement below, but maybe there have been a reason for its existence...

https://github.com/kelleyma49/PSFzf/blob/cba20d2c08619354f1022360c811cd48d3e8b451/PSFzf.TabExpansion.ps1#L324-L340

#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
        }
    }
    else {
        # no more paths to complete, so let's stop completion:
        $str += ' '
        $script:continueCompletion = $false
    }
#}