PSMenu icon indicating copy to clipboard operation
PSMenu copied to clipboard

Move save & restore logic inside Show-Menu

Open ElianFabian opened this issue 1 year ago • 0 comments

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
}

ElianFabian avatar Sep 04 '24 19:09 ElianFabian