Skip to content

Commit

Permalink
Fix the shortcut loading too
Browse files Browse the repository at this point in the history
  fixes #2319
  • Loading branch information
zadjii-msft committed Sep 3, 2019
1 parent 3d95ee8 commit a6cccea
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/propsheet/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void SaveConsoleSettingsIfNeeded(const HWND hwnd)
if (gpStateInfo->LinkTitle != NULL)
{
SetGlobalRegistryValues();
if (!NT_SUCCESS(ShortcutSerialization::s_SetLinkValues(gpStateInfo, g_fEastAsianSystem, g_fForceV2)))
if (!NT_SUCCESS(ShortcutSerialization::s_SetLinkValues(gpStateInfo, g_fEastAsianSystem, g_fForceV2, g_fLaunchedAsV2)))
{
WCHAR szMessage[MAX_PATH + 100];
WCHAR awchBuffer[MAX_PATH] = { 0 };
Expand Down
1 change: 1 addition & 0 deletions src/propsheet/registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,7 @@ VOID SetRegistryValues(
// Only save the "Terminal" settings if we launched as a v2 propsheet. The
// v1 console doesn't know anything about these settings, and their value
// will be incorrectly zero'd if we save in this state.
// See microsoft/terminal#2319 for more details.
if (g_fLaunchedAsV2)
{
// Save cursor type and color
Expand Down
22 changes: 16 additions & 6 deletions src/propslib/ShortcutSerialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,8 @@ Return Value:
*/
[[nodiscard]] NTSTATUS ShortcutSerialization::s_SetLinkValues(_In_ PCONSOLE_STATE_INFO pStateInfo,
const BOOL fEastAsianSystem,
const BOOL fForceV2)
const BOOL fForceV2,
const bool writeTerminalSettings)
{
IShellLinkW* psl;
IPersistFile* ppf;
Expand Down Expand Up @@ -488,12 +489,21 @@ Return Value:
s_SetLinkPropertyBoolValue(pps, PKEY_Console_CtrlKeyShortcutsDisabled, pStateInfo->fCtrlKeyShortcutsDisabled);
s_SetLinkPropertyBoolValue(pps, PKEY_Console_LineSelection, pStateInfo->fLineSelection);
s_SetLinkPropertyByteValue(pps, PKEY_Console_WindowTransparency, pStateInfo->bWindowTransparency);
s_SetLinkPropertyDwordValue(pps, PKEY_Console_CursorType, pStateInfo->CursorType);
s_SetLinkPropertyDwordValue(pps, PKEY_Console_CursorColor, pStateInfo->CursorColor);
s_SetLinkPropertyBoolValue(pps, PKEY_Console_InterceptCopyPaste, pStateInfo->InterceptCopyPaste);
s_SetLinkPropertyDwordValue(pps, PKEY_Console_DefaultForeground, pStateInfo->DefaultForeground);
s_SetLinkPropertyDwordValue(pps, PKEY_Console_DefaultBackground, pStateInfo->DefaultBackground);
s_SetLinkPropertyBoolValue(pps, PKEY_Console_TerminalScrolling, pStateInfo->TerminalScrolling);

// Only save the "Terminal" settings if we launched as a v2
// propsheet. The v1 console doesn't know anything about
// these settings, and their value will be incorrectly
// zero'd if we save in this state.
// See microsoft/terminal#2319 for more details.
if (writeTerminalSettings)
{
s_SetLinkPropertyDwordValue(pps, PKEY_Console_CursorType, pStateInfo->CursorType);
s_SetLinkPropertyDwordValue(pps, PKEY_Console_CursorColor, pStateInfo->CursorColor);
s_SetLinkPropertyDwordValue(pps, PKEY_Console_DefaultForeground, pStateInfo->DefaultForeground);
s_SetLinkPropertyDwordValue(pps, PKEY_Console_DefaultBackground, pStateInfo->DefaultBackground);
s_SetLinkPropertyBoolValue(pps, PKEY_Console_TerminalScrolling, pStateInfo->TerminalScrolling);
}
hr = pps->Commit();
pps->Release();
}
Expand Down
2 changes: 1 addition & 1 deletion src/propslib/ShortcutSerialization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Revision History:
class ShortcutSerialization
{
public:
[[nodiscard]] static NTSTATUS s_SetLinkValues(_In_ PCONSOLE_STATE_INFO pStateInfo, const BOOL fEastAsianSystem, const BOOL fForceV2);
[[nodiscard]] static NTSTATUS s_SetLinkValues(_In_ PCONSOLE_STATE_INFO pStateInfo, const BOOL fEastAsianSystem, const BOOL fForceV2, const bool writeTerminalSettings);
[[nodiscard]] static NTSTATUS s_GetLinkConsoleProperties(_Inout_ PCONSOLE_STATE_INFO pStateInfo);
[[nodiscard]] static NTSTATUS s_GetLinkValues(_Inout_ PCONSOLE_STATE_INFO pStateInfo,
_Out_ BOOL* const pfReadConsoleProperties,
Expand Down

0 comments on commit a6cccea

Please sign in to comment.