Skip to content

Conversation

@jianyunt
Copy link
Contributor

@jianyunt jianyunt commented Jun 8, 2018

Fix issue #707

We need the fix from the PowerShell to completely fix the issue.

@jianyunt
Copy link
Contributor Author

jianyunt commented Jun 8, 2018

Test.ReadLine.ViDefect651 does not fail on my dev box. Any ideas?

@lzybkr
Copy link
Contributor

lzybkr commented Jun 8, 2018

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/

// 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;
Copy link
Contributor

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();

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The multi-line case does not work. It becomes something like this. Any advices?

image

Copy link
Contributor Author

@jianyunt jianyunt Jul 13, 2018

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.

@jianyunt
Copy link
Contributor Author

jianyunt commented Jul 27, 2018

@lzybkr, I updated the code and tested. Could you please take look at it if we are good to go? Thanks!

@lzybkr lzybkr merged commit e5d1426 into PowerShell:master Aug 15, 2018
@jianyunt jianyunt deleted the extraspace branch August 17, 2018 23:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants