Skip to content

Commit

Permalink
be smart, use the first word as the application name
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Aug 17, 2023
1 parent fb588b8 commit c41895e
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/cascadia/TerminalSettingsModel/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,5 +338,26 @@ Json::Value Profile::ToJson() const
}
winrt::hstring Profile::EvaluatedIcon() const
{
return Icon().empty() ? Commandline() : Icon();
// If the profile has an icon, return it.
if (!Icon().empty())
{
return Icon();
}

// Otherwise, return the first word of the commandline - that should be the executable name.
std::wstring_view cmdline{ Commandline() };
if (cmdline.empty())
{
return {};
}

auto firstSpace = cmdline.find_first_of(L" ");
if (firstSpace == std::wstring::npos)
{
return winrt::hstring{ cmdline };
}
else
{
return winrt::hstring{ cmdline.substr(0, firstSpace) };
}
}

0 comments on commit c41895e

Please sign in to comment.