nightroman / FarNet

Far Manager framework for .NET modules and scripts in PowerShell, F#, JavaScript.
https://github.com/nightroman/FarNet/wiki
BSD 3-Clause "New" or "Revised" License
136 stars 19 forks source link

Please tell how can I modify TabExpansion2 to complete in lowercase #14

Closed ghost closed 6 years ago

ghost commented 6 years ago

How can I modify TabExpansion2 to complete in lowercase.

# Now
ls . -Force -Directory

# Wanted
ls . -force -directory

Thanks!

nightroman commented 6 years ago

Let me think a little bit. I have tried some straightforward conversion and it did not work (not sure why..).

nightroman commented 6 years ago

We can transform the final ${*}.result before returning it:

for($i = 0; $i -lt ${*}.result.CompletionMatches.Count; ++$i) {
    $r = ${*}.result.CompletionMatches[$i]
    ${*}.result.CompletionMatches[$i] = New-Object System.Management.Automation.CompletionResult @(
        $r.CompletionText.ToLower()
        $r.ListItemText
        $r.ResultType
        $r.ToolTip
    )
}
${*}.result

There are two places where we return it (actually 3, but one is special read-only). You may create a function doing this conversion and call it.

ghost commented 6 years ago

@nightroman Wow, thanks a lot!