From df221299d91d7f7667dafdca71baa2a622f0c25c Mon Sep 17 00:00:00 2001 From: iff Date: Wed, 27 Nov 2024 19:35:57 +0100 Subject: [PATCH] chore: format & endline white spaces --- src/shell.rs | 68 ++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/shell.rs b/src/shell.rs index 78e0508..ff0022f 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -208,25 +208,25 @@ def --env {} [] {{ ), "pwsh" | "powershell" => format!( r#"& {{ - try {{ - # fetch command and error from session history only when not in cnf mode - if ($env:_PR_MODE -ne 'cnf') {{ - $env:_PR_LAST_COMMAND = ({}); - $err = Get-Error; - if ($env:_PR_LAST_COMMAND -eq $err.InvocationInfo.Line) {{ - $env:_PR_ERROR_MSG = $err.Exception.Message - }} - }} - $env:_PR_SHELL = '{}'; - &'{}'; - }} - finally {{ - # restore mode from cnf - if ($env:_PR_MODE -eq 'cnf') {{ - $env:_PR_MODE = $env:_PR_PWSH_ORIGIN_MODE; - $env:_PR_PWSH_ORIGIN_MODE = $null; - }} - }} + try {{ + # fetch command and error from session history only when not in cnf mode + if ($env:_PR_MODE -ne 'cnf') {{ + $env:_PR_LAST_COMMAND = ({}); + $err = Get-Error; + if ($env:_PR_LAST_COMMAND -eq $err.InvocationInfo.Line) {{ + $env:_PR_ERROR_MSG = $err.Exception.Message + }} + }} + $env:_PR_SHELL = '{}'; + &'{}'; + }} + finally {{ + # restore mode from cnf + if ($env:_PR_MODE -eq 'cnf') {{ + $env:_PR_MODE = $env:_PR_PWSH_ORIGIN_MODE; + $env:_PR_PWSH_ORIGIN_MODE = $null; + }} + }} }} "#, last_command, shell, binary_path @@ -309,22 +309,22 @@ end "pwsh" | "powershell" => { init = format!( r#"{} -$ExecutionContext.InvokeCommand.CommandNotFoundAction = +$ExecutionContext.InvokeCommand.CommandNotFoundAction = {{ - param( - [string] - $commandName, - [System.Management.Automation.CommandLookupEventArgs] - $eventArgs - ) - # powershell does not support run command with specific environment variables - # but you must set global variables. so we are memorizing the current mode and the alias function will reset it later. - $env:_PR_PWSH_ORIGIN_MODE=$env:_PR_MODE; - $env:_PR_MODE='cnf'; - # powershell may search command with prefix 'get-' or '.\' first when this hook is hit, strip them - $env:_PR_LAST_COMMAND=$commandName -replace '^get-|\.\\',''; - $eventArgs.Command = (Get-Command {}); - $eventArgs.StopSearch = $True; + param( + [string] + $commandName, + [System.Management.Automation.CommandLookupEventArgs] + $eventArgs + ) + # powershell does not support run command with specific environment variables + # but you must set global variables. so we are memorizing the current mode and the alias function will reset it later. + $env:_PR_PWSH_ORIGIN_MODE=$env:_PR_MODE; + $env:_PR_MODE='cnf'; + # powershell may search command with prefix 'get-' or '.\' first when this hook is hit, strip them + $env:_PR_LAST_COMMAND=$commandName -replace '^get-|\.\\',''; + $eventArgs.Command = (Get-Command {}); + $eventArgs.StopSearch = $True; }} "#, init, auto_alias