You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PowerShell hook: engine history keeps the wrapped line in an interactive session #51
In an interactive PowerShell session with the capture hook, the engine history (Get-History, history, r) keeps the wrapped form of every captured line, for example . __cdg { git status }, instead of the line as typed. #48 was meant to put the typed line back before the next prompt, and its unit test passes.
Cause: __cdg is dot-sourced, and at the prompt that means into the global scope. Its local $__cdgLine = $global:__cdgLine is therefore the global variable itself, and the cleanup in its finally (Remove-Variable ... __cdgLine ...) deletes it. __cdgRestoreHistory then finds no line and returns without restoring. The unit test calls __cdgRestoreHistory directly, without __cdg, so it does not see this.
To reproduce: start pwsh -NoProfile, dot-source src/codigest/shell/hook.ps1 with cdg on PATH, run echo a, then echo b, then (Get-History).CommandLine. It lists . __cdg { echo a } and . __cdg { echo b }.
Activity