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

Fix issue with pasting while tab renaming also sending the paste command to terminal #14669

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 14 additions & 1 deletion src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2687,12 +2687,25 @@ namespace winrt::TerminalApp::implementation
fire_and_forget TerminalPage::_PasteFromClipboardHandler(const IInspectable /*sender*/, const PasteFromClipboardEventArgs eventArgs)
try
{
// Checking here if we are currently renaming any tab so that we should not paste content into our tab.
for (const auto item : _tabs)
{
if (const auto tabItem = item.try_as<TerminalTab>())
{
if (tabItem->InRename())
{
co_return;
}
}
}

const auto data = Clipboard::GetContent();
// The old Win32 clipboard API as used below is somewhere in the order of 300-1000x faster than
// the WinRT one on average, depending on CPU load. Don't use the WinRT clipboard API if you can.
const auto weakThis = get_weak();
const auto dispatcher = Dispatcher();
const auto globalSettings = _settings.GlobalSettings();

// GetClipboardData might block for up to 30s for delay-rendered contents.
co_await winrt::resume_background();

Expand Down
5 changes: 5 additions & 0 deletions src/cascadia/TerminalApp/TerminalTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,11 @@ namespace winrt::TerminalApp::implementation
return _zoomedPane != nullptr;
}

bool TerminalTab::InRename()
{
return _headerControl.InRename();
}

TermControl _termControlFromPane(const auto& pane)
{
if (const auto content{ pane->GetContent() })
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TerminalTab.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ namespace winrt::TerminalApp::implementation
void EnterZoom();
void ExitZoom();

bool InRename();
std::vector<Microsoft::Terminal::Settings::Model::ActionAndArgs> BuildStartupActions(BuildStartupKind kind) const override;

int GetLeafPaneCount() const noexcept;
Expand Down
Loading