Fix PowerShell completions not completing after directories containing spaces

This commit is contained in:
2024-07-09 14:29:15 -04:00
parent d749452943
commit e3aabfb7e4
2 changed files with 5 additions and 6 deletions
+4 -4
View File
@@ -1,10 +1,10 @@
function cliMUTNEntryCompleter {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
#$mutnPath = (Resolve-Path '~/.local/share/libmutton').Path # UNIX testing
$mutnPath = (Resolve-Path '~/AppData/Local/libmutton/entries').Path
$mutnPath = (Resolve-Path '~\AppData\Local\libmutton\entries').Path
try {
$trimmedPaths = If (Test-Path $mutnPath) {
(Get-ChildItem -Path $mutnPath -Recurse -File).FullName.Substring($mutnPath.Length) -replace '\\', '/' -replace ' ', '` '
(Get-ChildItem -Path $mutnPath -Recurse -File).FullName.Substring($mutnPath.Length) -replace '\\', '/' -replace ' ', [char]0x23bd
}
} catch {
$trimmedPaths = $null # if any errors occur (especially, "You cannot call a method on a null-valued expression", set $trimmedPaths to $null
@@ -50,6 +50,6 @@ function mutn {
[string]$option
)
#Invoke-Expression -Command ('/usr/local/bin/mutn ' + ($entry -replace ' ', '` '), $argument, $option).Trim() # UNIX testing
Invoke-Expression -Command ('./mutn.exe ' + ($entry -replace ' ', '` '), $argument, $option).Trim()
#Invoke-Expression -Command ('/usr/local/bin/mutn ' + ($entry -replace ' ', '` ' -replace [char]0x1a, '` '), $argument, $option).Trim() # UNIX testing
Invoke-Expression -Command ('mutn.exe ' + ($entry -replace ' ', '` ' -replace [char]0x23bd, '` '), $argument, $option).Trim()
}