Skip to content

Conversation

@jianyunt
Copy link
Contributor

@jianyunt jianyunt commented Jul 16, 2018

PR Summary

To address the issue #7022, the changes are among the following repos:

  • PSReadLine, see PR Set the cursor to the place where a user hits tab key PSReadLine#708
    For example, in the cloudshell, when a user types get-azurermvmac and then hits tab, we reach out to Azure to fetch the data and pwsh will show progress in the meantime, which in turn changes the cursor position. That requires PSReadLine to adjust the cursor position after calling GetCompletions().
  • This PR is for fixing the cursor position calculation issue in PSCore when scrolling up screen is necessary so the PSReadLine can set the cursor to the right location
  • With the above two fixes, the nested progress still does not work. I had a long conversation with @iSazonov in my previous PR Set the cursor to the place where a user hits tab key #7023. We cannot call hide() because there is a small window where the progress won't get cleaned if ctrl+c. Looking through the code, I think the easier way is to use the workaround $ProgressPreference ='SilentlyContinue' at the AzurePSDrive module level for nested case, see For nested write-progress, we suppress the progress in the azurepsdrive. AzurePSDrive#53.
    With that, we can still show the fetching Azure data progress written by SHiPS, suppress the progress in the Get-AzureRmWebApp , but it does not change the ProgressPreference setting in the cloudshell. This means when a user type Azure cmdlet, the progress will still show. That is the behavior we want.

Please note that we cannot use `$ProgressPreference ='SilentlyContinue' for both SHiPS and its provider AzurePSDrive because fetching data from Azure can take really long time. Showing progress is needed but keep (try keeping) one progress only. Thus the above fixes are all needed.

PR Checklist

}
if (scrollRows > 0)
{
// The following can be possibly replaced by Console.Write ("\x1b[" + scrollRows + "S");
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on PowerShell/PSReadLine#724, I'd remove this comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the comment. Thanks.

@iSazonov
Copy link
Collaborator

@jianyunt I do not have the ability to check this on Unix, but definitely we have to do many manual tests to make sure everything works without regression.

Copy link
Collaborator

@BrucePay BrucePay left a comment

Choose a reason for hiding this comment

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

LGTM

// Only generate these exceptions if a pipeline has already been declared as the 'writing' pipeline.
// Otherwise, these are probably infrastructure messages and can be ignored.
if (this.PipelineProcessor._permittedToWrite != null)
if (this.PipelineProcessor?._permittedToWrite != null)
Copy link
Member

Choose a reason for hiding this comment

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

Could you add comment why did change was made?

Copy link
Contributor Author

@jianyunt jianyunt Jul 27, 2018

Choose a reason for hiding this comment

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

The line 2249 has

if (this.PipelineProcessor == null || _thisCommand != this.PipelineProcessor._permittedToWrite ...

When I debug the code, i saw nullref exceptions here.
Yes the change has nothing to do with the cursor position. But it's good to get rid of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@adityapatwardhan In this case I don't think any comments are needed.

@anmenaga
Copy link

@adityapatwardhan This looks ready for merge.

@adityapatwardhan adityapatwardhan merged commit 344878d into PowerShell:master Aug 1, 2018
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.

6 participants