Repository navigation
When the profile icon is set to null, fall back to the icon of the commandline - #15843
Conversation
Why can't we make it so that there's a differentiation between |
|
Discussion notes:
|
…he icon of the commandline
| if (cmdline.empty()) | ||
| { | ||
| return {}; | ||
| } |
There was a problem hiding this comment.
FWIW you can remove this check. An empty wstring still returns a valid string via .c_str() ("") and so all the code below should still work.
| const size_t beforeNull{ ::wcslen(cmdline.c_str()) }; | ||
| const std::wstring_view exe{ cmdline.c_str(), beforeNull }; | ||
| return winrt::hstring{ exe }; |
There was a problem hiding this comment.
Just passing cmdline.c_str() to the hstring constructor will be fine. It has a hstring(wchar_t const* c) constructor, which calls wcslen for you. With the above comment this turns into:
const auto cmdline{ NormalizeCommandLine(Commandline().c_str()) };
// NormalizeCommandLine will return a string with embedded
// nulls after each arg. We just want the first one.
return winrt::hstring{ cmdline.c_str() };There was a problem hiding this comment.
I disagree generally that we should move from a smart string type to an hstring by using c_str. String types know their length; winrt::hstring(wchar_t*) must use wcslen to re-derive the length. Why do extra work?
There was a problem hiding this comment.
We only want to return the first segment of the double-null terminated string. (See the comment 😅)
…ult-to-commandline
…hub.com/microsoft/terminal into dev/migrie/b/705-default-to-commandline
…he icon of the commandline
| <comment>A supplementary setting to the "icon" setting.</comment> | ||
| </data> | ||
| <data name="Profile_HideIconCheckbox.[using:Windows.UI.Xaml.Controls]ToolTipService.ToolTip" xml:space="preserve"> | ||
| <value>If enabled, this will have no icon.</value> |
There was a problem hiding this comment.
| <value>If enabled, this will have no icon.</value> | |
| <value>If enabled, this profile will have no icon.</value> |
this what?
| winrt::hstring Profile::EvaluatedIcon() | ||
| { | ||
| // We cache the result here, so we don't search the path for the exe every time. | ||
| if (!_evaluatedIcon.has_value()) |
There was a problem hiding this comment.
hey, setting Icon doesn't invalidate this
There was a problem hiding this comment.
we never really set directly on a Profile tho do we? We instantiate a new one when we build a new settings object, but that'd come with an empty cached _evaluatedIcon
There was a problem hiding this comment.
Nah, the settings UI writes directly to Icon. It then fires local "Icon Changed" notifications and any listeners will probably re-call EvaluatedIcon (ugh)
There was a problem hiding this comment.
which may mean that setting an icon in the SUI doesn't update IN THE UI until you mash Save and it re-loads the entire tree
There was a problem hiding this comment.
but like, is that okay?
| winrt::hstring Profile::_evaluateIcon() const | ||
| { | ||
| // If the profile has an icon, return it. | ||
| if (!Icon().empty()) |
There was a problem hiding this comment.
can we not use our own member here?
There was a problem hiding this comment.
Nah, we can't because profile is layered so _Icon isn't the actual icon necessarily
…ult-to-commandline
…ult-to-commandline
…ult-to-commandline
The settings UI and settings model allow you to set the icon to "none" to hide the icon (you can actually see this effect in the settings UI when changing the value of the profile icon). However, during settings validation, "none" is considered a file path, which is then failed to be parsed, resulting in the icon being marked as invalid and immediately clearing the value. This PR fixes this issue by considering "none" to be an accepted value during validation. Related to #15843 Closes #17943 ## Validation Steps Performed When an icon is set to "none", ... ✅ no more warning ✅ the icon is hidden
The settings UI and settings model allow you to set the icon to "none" to hide the icon (you can actually see this effect in the settings UI when changing the value of the profile icon). However, during settings validation, "none" is considered a file path, which is then failed to be parsed, resulting in the icon being marked as invalid and immediately clearing the value. This PR fixes this issue by considering "none" to be an accepted value during validation. Related to #15843 Closes #17943 ## Validation Steps Performed When an icon is set to "none", ... ✅ no more warning ✅ the icon is hidden (cherry picked from commit 36f064c) Service-Card-Id: PVTI_lADOAF3p4s4AmhmszgTyV8A Service-Version: 1.21
The settings UI and settings model allow you to set the icon to "none" to hide the icon (you can actually see this effect in the settings UI when changing the value of the profile icon). However, during settings validation, "none" is considered a file path, which is then failed to be parsed, resulting in the icon being marked as invalid and immediately clearing the value. This PR fixes this issue by considering "none" to be an accepted value during validation. Related to #15843 Closes #17943 ## Validation Steps Performed When an icon is set to "none", ... ✅ no more warning ✅ the icon is hidden (cherry picked from commit 36f064c) Service-Card-Id: PVTI_lADOAF3p4s4AmhmQzgTyV8E Service-Version: 1.22

Basically, title. If you null out the icon, we'll automatically try to use the
commandlineas an icon (because we can now). We'll even be smart about it -cmd.exe /k echo wassupwill still just use the ico ofcmd.exe.This doesn't work for
ubuntu.exe(et. al), because that commandline is technically a reparse point, that doesn't actually have an icon associated with it.Closes #705
"none"becomes our sentinel value for "no icon".This will also use the same
NormalizeCommandLinewe use for commandline matching for finding the full path to the exe.