mirror of
https://github.com/microsoft/terminal.git
synced 2026-05-21 06:18:34 +00:00
Only set startingTitle once, clear up title fallback handling (#20214)
This commit ensures that we only set the starting title once when we
open a new terminal pane.
It also consolidates all title selection into Terminal::GetConsoleTitle,
which is now used in the TitleChanged event.
TitleChanged no longer stores a separate copy of the starting title if
an application attempts to _clear_ the title; that seems like a poorer
implementation of what we already had.
This supersedes work in #20204.
Closes #19340
Closes #20204
Co-authored-by: imsh <im.shaedar@gmail.com>
(cherry picked from commit b991eb048e)
Service-Card-Id: PVTI_lADOAF3p4s4BQX0-zgmWldU
Service-Version: 1.25
This commit is contained in:
committed by
Dustin L. Howett
parent
f49bcdd43a
commit
da1c5597cd
@@ -98,7 +98,6 @@ void Terminal::UpdateSettings(ICoreSettings settings)
|
|||||||
_answerbackMessage = settings.AnswerbackMessage();
|
_answerbackMessage = settings.AnswerbackMessage();
|
||||||
_wordDelimiters = settings.WordDelimiters();
|
_wordDelimiters = settings.WordDelimiters();
|
||||||
_suppressApplicationTitle = settings.SuppressApplicationTitle();
|
_suppressApplicationTitle = settings.SuppressApplicationTitle();
|
||||||
_startingTitle = settings.StartingTitle();
|
|
||||||
_trimBlockSelection = settings.TrimBlockSelection();
|
_trimBlockSelection = settings.TrimBlockSelection();
|
||||||
_autoMarkPrompts = settings.AutoMarkPrompts();
|
_autoMarkPrompts = settings.AutoMarkPrompts();
|
||||||
_rainbowSuggestions = settings.RainbowSuggestions();
|
_rainbowSuggestions = settings.RainbowSuggestions();
|
||||||
@@ -124,6 +123,11 @@ void Terminal::UpdateSettings(ICoreSettings settings)
|
|||||||
// Save the changes made above and in UpdateAppearance as the new default render settings.
|
// Save the changes made above and in UpdateAppearance as the new default render settings.
|
||||||
GetRenderSettings().SaveDefaultSettings();
|
GetRenderSettings().SaveDefaultSettings();
|
||||||
|
|
||||||
|
if (!_startingTitle)
|
||||||
|
{
|
||||||
|
_startingTitle = settings.StartingTitle();
|
||||||
|
}
|
||||||
|
|
||||||
if (!_startingTabColor && settings.StartingTabColor())
|
if (!_startingTabColor && settings.StartingTabColor())
|
||||||
{
|
{
|
||||||
_startingTabColor = settings.StartingTabColor().Value();
|
_startingTabColor = settings.StartingTabColor().Value();
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ private:
|
|||||||
::Microsoft::Console::VirtualTerminal::TerminalInput _terminalInput;
|
::Microsoft::Console::VirtualTerminal::TerminalInput _terminalInput;
|
||||||
|
|
||||||
std::optional<std::wstring> _title;
|
std::optional<std::wstring> _title;
|
||||||
std::wstring _startingTitle;
|
std::optional<std::wstring> _startingTitle;
|
||||||
std::optional<til::color> _startingTabColor;
|
std::optional<til::color> _startingTabColor;
|
||||||
|
|
||||||
std::vector<til::point_span> _searchHighlights;
|
std::vector<til::point_span> _searchHighlights;
|
||||||
|
|||||||
@@ -91,8 +91,12 @@ void Terminal::SetWindowTitle(const std::wstring_view title)
|
|||||||
_assertLocked();
|
_assertLocked();
|
||||||
if (!_suppressApplicationTitle)
|
if (!_suppressApplicationTitle)
|
||||||
{
|
{
|
||||||
_title.emplace(title.empty() ? _startingTitle : title);
|
_title.reset();
|
||||||
_pfnTitleChanged(_title.value());
|
if (!title.empty())
|
||||||
|
{
|
||||||
|
_title.emplace(title);
|
||||||
|
}
|
||||||
|
_pfnTitleChanged(GetConsoleTitle());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -184,11 +184,18 @@ void Terminal::SelectNewRegion(const til::point coordStart, const til::point coo
|
|||||||
std::wstring_view Terminal::GetConsoleTitle() const noexcept
|
std::wstring_view Terminal::GetConsoleTitle() const noexcept
|
||||||
{
|
{
|
||||||
_assertLocked();
|
_assertLocked();
|
||||||
if (_title.has_value())
|
|
||||||
|
if (_title)
|
||||||
{
|
{
|
||||||
return *_title;
|
return *_title;
|
||||||
}
|
}
|
||||||
return _startingTitle;
|
|
||||||
|
if (_startingTitle)
|
||||||
|
{
|
||||||
|
return *_startingTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method Description:
|
// Method Description:
|
||||||
|
|||||||
Reference in New Issue
Block a user