Skip to content
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

WindowTitle set by user overwritten by module #594

Closed
nairby opened this issue Jul 6, 2018 · 6 comments · Fixed by #597
Closed

WindowTitle set by user overwritten by module #594

nairby opened this issue Jul 6, 2018 · 6 comments · Fixed by #597

Comments

@nairby
Copy link

nairby commented Jul 6, 2018

System Details

  • posh-git version/path: 1.0.0 beta2 ~\Documents\WindowsPowerShell\Modules\posh-git\1.0.0
  • PowerShell version: 5.1.17134.112
  • git version 2.18.0.windows.1
  • OS: Microsoft Windows NT 10.0.17134.0

Issue Description

I have the following in my $profile:

Import-Module posh-git
$GitPromptSettings.WindowTitle = $null

If I start a script that changes $host.UI.RawUI.WindowTitle directly then this still gets overwritten with $PreviousWindowTitle that was initialised with the text from when the PowerShell window was started. I would like my script to be able to change the title and have the same effect regardless of whether posh-git is loaded.

I know there has been some discussion about this before in previous issues - but could it be considered that a setting could be added to $GitPromptSettings to disable any update of $host.UI.RawUI.WindowTitle?

Maybe this could also be added as a parameter when the module starts so that the WindowTitle never gets updated or changed by the module (and hence would not need to be reverted to $PreviousWindowTitle).

@dahlbyk
Copy link
Owner

dahlbyk commented Jul 6, 2018

It seems to me that setting $GitPromptSettings.WindowTitle to $null/$false should completely disable any window title fiddling.

Module parameters are a rather poor experience, so I'm more inclined to defer $WindowTitleSupported initialization until the first prompt runs (and only initialize at all if $GitPromptSettings.WindowTitle isn't $null/$false at that time). Does that seem reasonable?

@nairby
Copy link
Author

nairby commented Jul 9, 2018

@dahlbyk - Yes, agree that the window title should be left alone if $GitPromptSettings.WindowTitle is $null/$false

@rkeithhill
Copy link
Collaborator

rkeithhill commented Jul 10, 2018

It seems to me that setting $GitPromptSettings.WindowTitle to $null/$false should completely disable any window title fiddling.

So the issue is that if someone disables $GitPromptSettings.WindowTitle interactively, we were using $PreviousWindowTitle to set the Window title back to the original "Windows PowerShell" title. Unfortunately, as long as $GitPromptSettings.WindowTitle is $null, we set the WindowTitle to $PreviousWindowTitle (which is better named OriginalWindowTitle or something like that). Perhaps we just punt on this admittedly corner case scenario of a user interactively disabling the WindowTitle? If if someone does this, their WindowTitle will be stuck to what it was when they disabled it.

@dahlbyk
Copy link
Owner

dahlbyk commented Jul 10, 2018

Perhaps we just punt on this admittedly corner case scenario of a user interactively disabling the WindowTitle? If if someone does this, their WindowTitle will be stuck to what it was when they disabled it.

I'm fine with this. The primary use case here is setting a personal preference in $PROFILE.

@rkeithhill
Copy link
Collaborator

Sounds good. I'll submit a PR for this tonight.

rkeithhill added a commit that referenced this issue Jul 11, 2018
We used to restore the previousWindowTitle but this had the effect of
always updating the WindowTitle with a fixed string - whatever we
captured in $PreviousWindowTitle.

However, we still restore the original window title when the module is
removed. But we only do this if the module is configured to supply the
window title.

Rename variable to make its intent clearer.

Fixes #594
@rkeithhill
Copy link
Collaborator

@dahlbyk Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants