PSMenu
PSMenu copied to clipboard
Move save & restore logic inside Show-Menu
Currently, as mentioned in the README file, we have to manually save and restore the cursor position. This can be streamlined by incorporating that logic directly into the Show-Menu function. Below is an example of how the code can be changed:
# Before
If ($Callback) {
& $Callback
Start-Sleep -Milliseconds 10
}
# After
If ($Callback) {
$lastTop = [Console]::CursorTop
& $Callback
[System.Console]::SetCursorPosition(0, $lastTop)
Start-Sleep -Milliseconds 10
}