-
Notifications
You must be signed in to change notification settings - Fork 319
Set the cursor to the place where a user hits tab key #708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Test.ReadLine.ViDefect651 does not fail on my dev box. Any ideas? |
|
ViDefect651 passes for me as well with your change. I can't think of anything obvious. You can debug in AppVeyor, see https://www.appveyor.com/docs/how-to/rdp-to-build-worker/ |
…hanges its location
PSReadLine/Completion.cs
Outdated
| // GetCompletions can triager the PowerShell Write-Progress that may scroll the console screen. | ||
| // For example, cd and hit the tab under the CloudShell Azure drive, it will go out to fetch data and show the | ||
| // progress bar. We need to update the _initialY in case the current cursor postion has changed. | ||
| _singleton._initialY = _console.CursorTop; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This scenario is very similar to the InvokePrompt scenario where somebody explicitly wants to call their prompt function to update some status or whatever - and after that, the cursor may have moved.
In the InvokePrompt scenario, we render the entire command line (all lines) because either the cursor moved or we erased the previous prompt.
I think this scenario is equivalent, and if I'm correct, I think the code from InvokePrompt should be extracted into a function so it can be shared.
The code in question is:
_singleton._initialX = console.CursorLeft;
_singleton._initialY = console.CursorTop;
_singleton._previousRender = _initialPrevRender;
_singleton.Render();There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lzybkr Yes this scenario is very similar to the InvokePrompt. Both may change the cursor position. And for the tab Completion case, if a user do get<tab>, the cursor is expected to set back to right after get, right? This means _initialX has no change. If we update _singleton._initialX = console.CursorLeft, we get getGet back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, _initialX shouldn't change in your scenario, so now I'm just wondering if you might need the other 2 lines to render properly.
Can you test all the ways GetCompletions is called - I can think of 4 - Complete, TabCompleteNext, PossibleCompletions, and MenuComplete. I would test all of those with the completion on the first line, and again with the completion on a second line (multi-line input), and also where the completion is near the end of the line.
If the display is fine in all of those scenarios without calling Render (in other words, exactly how the code is now), then we can call it good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the code and tested on Windows and Linux with the following cases:
Complete, PossibleCompletions, MenuComplete, TabCompletNext, multipleline such as start-job{..}, close to end of the line. Works as expected now.
bc9713b to
53d8bda
Compare
|
@lzybkr, I updated the code and tested. Could you please take look at it if we are good to go? Thanks! |

Fix issue #707
We need the fix from the PowerShell to completely fix the issue.