Skip to content

Commit 9a0d808

Browse files
authored
Respect TabExpansion2 by passing a [PowerShell] instance to CompleteInput (#356)
1 parent 60f6df9 commit 9a0d808

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

PSFzf.TabExpansion.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,18 @@ function script:Invoke-FzfTabCompletionInner() {
244244
return $false
245245
}
246246

247+
$runspace = Get-Runspace
248+
$runspaceIsRemote = $null -ne $runspace -and $null -ne $runspace.ConnectionInfo
249+
if (-not $runspaceIsRemote) {
250+
$ps = [System.Management.Automation.PowerShell]::Create('CurrentRunspace')
251+
}
252+
else {
253+
$ps = [System.Management.Automation.PowerShell]::Create()
254+
$ps.Runspace = $runspace
255+
}
256+
247257
try {
248-
$completions = [System.Management.Automation.CommandCompletion]::CompleteInput($line, $cursor, @{})
258+
$completions = [System.Management.Automation.CommandCompletion]::CompleteInput($line, $cursor, @{}, $ps)
249259
}
250260
catch {
251261
# some custom tab completions will cause CompleteInput() to throw, so we gracefully handle those cases.

0 commit comments

Comments
 (0)