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

Teach tab to focus terminal after rename #9162

Merged
3 commits merged into from
Feb 17, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/cascadia/TerminalApp/TabHeaderControl.cpp
Expand Up @@ -106,7 +106,11 @@ namespace winrt::TerminalApp::implementation
// - Hides the rename box and displays the title text block
void TabHeaderControl::_CloseRenameBox()
{
HeaderRenamerTextBox().Visibility(Windows::UI::Xaml::Visibility::Collapsed);
HeaderTextBlock().Visibility(Windows::UI::Xaml::Visibility::Visible);
if (HeaderRenamerTextBox().Visibility() == Windows::UI::Xaml::Visibility::Visible)
{
HeaderRenamerTextBox().Visibility(Windows::UI::Xaml::Visibility::Collapsed);
HeaderTextBlock().Visibility(Windows::UI::Xaml::Visibility::Visible);
_RenameEndedHandlers(*this, nullptr);
}
}
}
2 changes: 2 additions & 0 deletions src/cascadia/TerminalApp/TabHeaderControl.h
Expand Up @@ -25,6 +25,8 @@ namespace winrt::TerminalApp::implementation
OBSERVABLE_GETSET_PROPERTY(double, RenamerMaxWidth, _PropertyChangedHandlers);
OBSERVABLE_GETSET_PROPERTY(winrt::TerminalApp::TerminalTabStatus, TabStatus, _PropertyChangedHandlers);

TYPED_EVENT(RenameEnded, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable);

private:
bool _receivedKeyDown{ false };
bool _renameCancelled{ false };
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TabHeaderControl.idl
Expand Up @@ -17,5 +17,6 @@ namespace TerminalApp
TerminalTabStatus TabStatus { get; set; };

event TitleChangeRequestedArgs TitleChangeRequested;
event Windows.Foundation.TypedEventHandler<Object, Object> RenameEnded;
}
}
13 changes: 13 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Expand Up @@ -858,6 +858,19 @@ namespace winrt::TerminalApp::implementation
}
});

newTabImpl->TabRenamerDeactivated([weakThis{ get_weak() }](auto&& /*s*/, auto&& /*e*/) {
if (const auto page{ weakThis.get() })
{
if (!page->_newTabButton.Flyout().IsOpen())
{
if (const auto tab{ page->_GetFocusedTab() })
{
tab.Focus(FocusState::Programmatic);
}
}
}
});

if (debugConnection) // this will only be set if global debugging is on and tap is active
{
TermControl newControl{ settings, debugConnection };
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TerminalTab.h
Expand Up @@ -89,6 +89,7 @@ namespace winrt::TerminalApp::implementation
DECLARE_EVENT(ColorSelected, _colorSelected, winrt::delegate<winrt::Windows::UI::Color>);
DECLARE_EVENT(ColorCleared, _colorCleared, winrt::delegate<>);
DECLARE_EVENT(TabRaiseVisualBell, _TabRaiseVisualBellHandlers, winrt::delegate<>);
FORWARDED_TYPED_EVENT(TabRenamerDeactivated, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, (&_headerControl), RenameEnded);

private:
std::shared_ptr<Pane> _rootPane{ nullptr };
Expand Down