mirror of
https://github.com/Llewellynvdm/starship.git
synced 2025-01-29 01:58:24 +00:00
fix(init/pwsh): preserve ViModeChangeHandler (#6225)
* Combine ViModeChangeHandler If a user has defined a ViModeChangeHandler setting this would respect that as well as redraw the prompt (to allow rendering things like the character change). * Add newline * Use call operator to limit new closure scope * Pass any args to original handler
This commit is contained in:
parent
1f4b664cff
commit
9b6d394e01
@ -211,9 +211,21 @@ $null = New-Module starship {
|
|||||||
)
|
)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
# Combine user defined ViModeChangeHandler if it exists
|
||||||
|
if((Get-PSReadLineOption).ViModeChangeHandler){
|
||||||
|
# &{...} to limit the scope of the GetNewClosure
|
||||||
|
& {
|
||||||
|
$originalHandler = (Get-PSReadLineOption).ViModeChangeHandler
|
||||||
|
Set-PSReadLineOption -ViModeChangeHandler {
|
||||||
|
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
|
||||||
|
& $originalHandler @args
|
||||||
|
}.GetNewClosure()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
Set-PSReadLineOption -ViModeIndicator script -ViModeChangeHandler {
|
Set-PSReadLineOption -ViModeIndicator script -ViModeChangeHandler {
|
||||||
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
|
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
||||||
Export-ModuleMember -Function @(
|
Export-ModuleMember -Function @(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user