nightroman / FarNet

Far Manager framework for .NET modules and scripts in PowerShell, F#, JavaScript.
https://github.com/nightroman/FarNet/wiki
BSD 3-Clause "New" or "Revised" License
136 stars 19 forks source link

PSF RawUI must not be bound to ShowUserScreen #5

Closed nightroman closed 8 years ago

nightroman commented 8 years ago

It was tempting to ShowUserScreen from RawUI set-members and it was done in PSF 5.2.2. It is a bad idea. PS core may call these members unexpectedly, and from other threads, too.

In other words, raw console API must not be bound to Far API, at least not to ShowUserScreen.

Symptoms in 5.2.2

Type something in the command line and call PSF TabExpansion. As a result, the user screen is shown unexpectedly and the completion menu is shown at the left most position, not at the expected caret position on typing.

It turns out PS plays with ForegroundColor when we call TabExpansion. We cannot control and avoid such calls. Even if we add an ugly workaround for this use case, we will not solve the problem in other similar cases.