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

[pull] main from microsoft:main #179

Merged
merged 2 commits into from
May 16, 2024
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
7 changes: 5 additions & 2 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,10 @@ namespace winrt::TerminalApp::implementation

void TerminalPage::PersistState()
{
if (_startupState != StartupState::Initialized)
// This method may be called for a window even if it hasn't had a tab yet or lost all of them.
// We shouldn't persist such windows.
const auto tabCount = _tabs.Size();
if (_startupState != StartupState::Initialized || tabCount == 0)
{
return;
}
Expand All @@ -1915,7 +1918,7 @@ namespace winrt::TerminalApp::implementation

// if the focused tab was not the last tab, restore that
auto idx = _GetFocusedTabIndex();
if (idx && idx != _tabs.Size() - 1)
if (idx && idx != tabCount - 1)
{
ActionAndArgs action;
action.Action(ShortcutAction::SwitchToTab);
Expand Down
4 changes: 3 additions & 1 deletion src/cascadia/TerminalConnection/ConptyConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,14 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
const HANDLE hRef,
const HANDLE hServerProcess,
const HANDLE hClientProcess,
TERMINAL_STARTUP_INFO startupInfo) :
const TERMINAL_STARTUP_INFO& startupInfo) :
_rows{ 25 },
_cols{ 80 },
_inPipe{ hIn },
_outPipe{ hOut }
{
_sessionId = Utils::CreateGuid();

THROW_IF_FAILED(ConptyPackPseudoConsole(hServerProcess, hRef, hSig, &_hPC));
_piClient.hProcess = hClientProcess;

Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalConnection/ConptyConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
const HANDLE hRef,
const HANDLE hServerProcess,
const HANDLE hClientProcess,
TERMINAL_STARTUP_INFO startupInfo);
const TERMINAL_STARTUP_INFO& startupInfo);

ConptyConnection() noexcept = default;
void Initialize(const Windows::Foundation::Collections::ValueSet& settings);
Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalCore/TerminalApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ TRACELOGGING_DEFINE_PROVIDER(g_hCTerminalCoreProvider,

void Terminal::ReturnResponse(const std::wstring_view response)
{
if (_pfnWriteInput)
if (_pfnWriteInput && !response.empty())
{
const auto suspension = _readWriteLock.suspend();
_pfnWriteInput(response);
}
}
Expand Down
Loading