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

Set tab title as early as possible #6433

Merged
1 commit merged into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ namespace winrt::TerminalApp::implementation
void Tab::_MakeTabViewItem()
{
_tabViewItem = ::winrt::MUX::Controls::TabViewItem{};
_UpdateTitle();
}

// Method Description:
Expand Down
2 changes: 2 additions & 0 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ namespace winrt::Microsoft::Terminal::TerminalControl::implementation
auto inputFn = std::bind(&TermControl::_SendInputToConnection, this, std::placeholders::_1);
_terminal->SetWriteInputCallback(inputFn);

_terminal->UpdateSettings(settings);

// Subscribe to the connection's disconnected event and call our connection closed handlers.
_connectionStateChangedRevoker = _connection.StateChanged(winrt::auto_revoke, [this](auto&& /*s*/, auto&& /*v*/) {
_ConnectionStateChangedHandlers(*this, nullptr);
Expand Down
14 changes: 6 additions & 8 deletions src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,6 @@ void Terminal::CreateFromSettings(winrt::Microsoft::Terminal::Settings::ICoreSet
Create(viewportSize, Utils::ClampToShortMax(settings.HistorySize(), 0), renderTarget);

UpdateSettings(settings);

if (_suppressApplicationTitle)
{
_title = _startingTitle;
}
}

// Method Description:
Expand Down Expand Up @@ -130,9 +125,12 @@ void Terminal::UpdateSettings(winrt::Microsoft::Terminal::Settings::ICoreSetting
break;
}

_buffer->GetCursor().SetStyle(settings.CursorHeight(),
settings.CursorColor(),
cursorShape);
if (_buffer)
{
_buffer->GetCursor().SetStyle(settings.CursorHeight(),
settings.CursorColor(),
cursorShape);
}

for (int i = 0; i < 16; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalCore/Terminal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Microsoft::Terminal::Core::Terminal final :
std::unique_ptr<::Microsoft::Console::VirtualTerminal::StateMachine> _stateMachine;
std::unique_ptr<::Microsoft::Console::VirtualTerminal::TerminalInput> _terminalInput;

std::wstring _title;
std::optional<std::wstring> _title;
std::wstring _startingTitle;

std::array<COLORREF, XTERM_COLOR_TABLE_SIZE> _colorTable;
Expand Down
9 changes: 5 additions & 4 deletions src/cascadia/TerminalCore/TerminalApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,11 @@ CATCH_LOG_RETURN_FALSE()
bool Terminal::SetWindowTitle(std::wstring_view title) noexcept
try
{
_title = _suppressApplicationTitle ? _startingTitle : title;

_pfnTitleChanged(_title);

if (!_suppressApplicationTitle)
{
_title.emplace(title);
_pfnTitleChanged(_title.value());
}
return true;
}
CATCH_LOG_RETURN_FALSE()
Expand Down
6 changes: 5 additions & 1 deletion src/cascadia/TerminalCore/terminalrenderdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,11 @@ void Terminal::SelectNewRegion(const COORD coordStart, const COORD coordEnd)
const std::wstring Terminal::GetConsoleTitle() const noexcept
try
{
return _title;
if (_title.has_value())
{
return _title.value();
}
return _startingTitle;
}
catch (...)
{
Expand Down