mirror of
https://github.com/Llewellynvdm/starship.git
synced 2025-01-15 19:26:50 +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,8 +211,20 @@ $null = New-Module starship {
|
||||
)
|
||||
|
||||
try {
|
||||
Set-PSReadLineOption -ViModeIndicator script -ViModeChangeHandler {
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
|
||||
# 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 {
|
||||
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user