Putting results of ocgv on command line erases cursor
See original GitHub issueI may be missing something, but this feels like a bug in GraphicalTools
:
I want to define F7
as “Show command history using ocgv”:
$parameters = @{
Key = 'F7'
BriefDescription = 'ShowHistoryOcgv'
LongDescription = 'Show History using Out-ConsoleGridView'
ScriptBlock = {
param($key, $arg) # The arguments are ignored in this example
$history = Get-History -Count 100 | Out-ConsoleGridView -Title "Select Command" -OutputMode Single
if (-Not [string]::IsNullOrWhiteSpace($history)){
[Microsoft.PowerShell.PSConsoleReadLine]::Insert($history)
}
}
}
Set-PSReadLineKeyHandler @parameters
If I hit F7
I get, as expected:
I hit ENTER
and get:
So, it put the item I selected (ls
) on the command line, but nuked my prompt.
(I’ve tested this without posh-git
and oh-my-posh
in-play and it reproduces, so it’s not related to that).
This may be a psreadline
issue? Or I may not have written ShowHistoryOcgv
correctly.
But I think it’s related to GraphicalTools
because If I change my $history =
above to:
$history = Get-History -Count 1
It works as expected.
This works as expected as well:
$history = Get-History -Count 100 | Out-GridView -Title "Select Command" -PassThru
Anyone have any insight?
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
Delete from cursor position until end of line in command- ...
I am trying to emulate readline keybindings in insert and command-line modes (for example, <C-u> for deleting from cursor position to ...
Read more >Fastest way(s) to move the cursor on a terminal command ...
Ctrl-e Move to the end of the line. Meta-f Move forward a word, where a word is composed of letters and digits. Meta-b...
Read more >Delete command line after cursor position - conemu
Manipulation with command line is a shell function. ... Try clink for cmd, PSReadLine for PowerShell, or even bash from cygwin or MsysGit....
Read more >Bash: delete word ahead of cursor - command line
Bash: delete word ahead of cursor · Ctrl u is an option for erasing from cursor location to beginning... · Try alt +...
Read more >5 ways to navigate the Linux terminal faster
Similarly, CTRL+K erases everything from the current cursor position to the end of the line. Shortcuts: Instead of Backspace, use CTRL+U.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just verified the bad behavior described here does not repro on Linux. My little F7 script above works awesome under Ubuntu on WSL!
Not 100% confident this is the root of the problem yet, but
WindowsDriver.cs
does aConsole.Clear()
before it ends up callingCreateConsoleScreenBuffer
as shown above. Thus, even thought the logic is there to allocate and use a different screen buffer, it clears the existing one.