-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
New Tab Menu Customization #13763
New Tab Menu Customization #13763
Changes from 1 commit
7e922ab
88a336b
cec114e
294c13a
6676785
ea62c28
1d5f6d3
40f2a3e
b140c75
fc18f1f
2e6f1ce
bc628f6
7b7dc4f
46a09a4
14f6ece
af0515a
5425298
6bceb8c
e5d81a1
6239a7f
afc2f0b
77304b7
b7f915f
547b500
7ee3602
86fb995
2473709
ac703df
ec176b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,22 +43,31 @@ winrt::com_ptr<NewTabMenuEntry> MatchProfilesEntry::FromJson(const Json::Value& | |
|
||
bool MatchProfilesEntry::MatchesProfile(const Model::Profile& profile) | ||
{ | ||
auto isMatching = false; | ||
// We use an optional here instead of a simple bool directly, since there is no | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kinda wonder if we want the opposite behavior! Matching with no conditions means everything passes... that would let us simplify the logic as in my farther-down comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zadjii-msft Does that make sense to you, or did I countermand you? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure, to me it wouldn't feel intuitive that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huh. I've been thinking about it all night, and honestly both seem alright, so I think we should just pick one and go with it. Having no conditions match everything kinda makes sense - you start with everything, and each property filters that list down more. Having it match nothing also makes sense - there's no properties, so that doesn't really make sense as an entry, and then it just gets ignored. (also, I've got the plague now too so I might need @DHowett to finish driving this one down) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we do decide for default everything, then naming it |
||
// sensible default value for the desired semantics: the first property we want | ||
// to match on should always be applied (so one would set "true" as a default), | ||
// but if none of the properties are set, the default return value should be false | ||
// since this entry type is expected to behave like a positive match/whitelist. | ||
// | ||
// The easiest way to deal with this neatly is to use an optional, then for any | ||
// property to match we consider a null value to be "true", and for the return | ||
// value of the function we consider the null value to be "false". | ||
auto isMatching = std::optional<bool>{}; | ||
|
||
if (!_Name.empty()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this is now a union of all the properties, not the intersection. I feel like we should probably make it the conjunction. If it's a disjunction, there's no way to filter on multiple properties at once. If it's an intersection instead, then you can still get a union by just adding one entry per property There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since it's now a separate function, I'll write a quick fix for it tonight. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Luckily for you, European tonight is already now ;) It should now have conjunction semantics. |
||
{ | ||
isMatching = isMatching || _Name == profile.Name(); | ||
isMatching = { isMatching.value_or(true) && _Name == profile.Name() }; | ||
} | ||
|
||
if (!_Source.empty()) | ||
{ | ||
isMatching = isMatching || _Source == profile.Source(); | ||
isMatching = { isMatching.value_or(true) && _Source == profile.Source() }; | ||
} | ||
|
||
if (!_Commandline.empty()) | ||
{ | ||
isMatching = isMatching || _Commandline == profile.Commandline(); | ||
isMatching = { isMatching.value_or(true) && _Commandline == profile.Commandline() }; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be collapsed to...
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only if we want the no-filter case to return all profiles; otherwise this would not work properly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, I find that I am only really reacting to the This is an even sillier (but I don't know, more straightforward?) way to handle it.
0 conditions, 0 matches (thanks to all the do I love it? i dunno, not really any more than There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do generally agree about match vs filter, and I accept that we want match! Sorry, I didn't make that clear. :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I dislike the other setup a bit. Neither way is amazing though, so feel free to pick what you think is best. |
||
|
||
return isMatching; | ||
return isMatching.value_or(false); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little bit hesitant with this method, actually. Right now, we're giving two masters control over when entries are visible:
TerminalPage
makes its own decisions for each type of entry independently from this one, except when it asks aFolder
and thenFolder
makes decisions and reports back toPage
. Now, this doesn't hide any of the complexity fromPage
: it still needs to check whether a folder is empty, inlined, or forced to display as empty.I'm not sure that this is more centralized. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't like this. In a way, it's just view logic. But then it's also partly functional logic. Putting all the filtering in the
TerminalPage
felt like a bad idea, since we also can't access the implementation types there, but putting view logic in the models also felt dirty. Any ideas on how to fix this?