Skip to content

Commit

Permalink
Make opening the settings file more robust (microsoft#1841)
Browse files Browse the repository at this point in the history
* Make opening the settings file more robust

This fixes two issues.

 * Opens the assigned default application regardless of its configuration.
   Gvim for example only reacts to the "edit" verb so when selected as default application won't open.
   Using nullptr results in using the first specified application.
   This fixes microsoft#1789
 * If no application is assigned for json files fall back to notepad

 See https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea for more details
 especially why the result code checking is so horrific.

* Fix c-style cast
  • Loading branch information
maru-sama authored and mcpiroman committed Jul 23, 2019
1 parent e933123 commit c486bae
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/cascadia/TerminalApp/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,12 @@ namespace winrt::TerminalApp::implementation
co_await winrt::resume_background();

const auto settingsPath = CascadiaSettings::GetSettingsPath();
ShellExecute(nullptr, L"open", settingsPath.c_str(), nullptr, nullptr, SW_SHOW);

HINSTANCE res = ShellExecute(nullptr, nullptr, settingsPath.c_str(), nullptr, nullptr, SW_SHOW);
if (static_cast<int>(reinterpret_cast<uintptr_t>(res)) <= 32)
{
ShellExecute(nullptr, nullptr, L"notepad", settingsPath.c_str(), nullptr, SW_SHOW);
}
}

// Method Description:
Expand Down

0 comments on commit c486bae

Please sign in to comment.