Repository navigation
Bold matching text in the command palette - #7977
Dustin L. Howett (DHowett) merged 25 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
|
Dustin L. Howett (@DHowett), Mike Griese (@zadjii-msft) - this is not done yet, but I wanted to share this one to see that the direction is OK. My next steps are:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Mike Griese (@zadjii-msft) - can you please take a look? I believe it is starting to take a shape. |
This comment has been minimized.
This comment has been minimized.
Mike Griese (zadjii-msft)
left a comment
There was a problem hiding this comment.
Sorry for the delay - I'm still technically on paternity so I'm only working 50% time
Overall, I think this looks like a fine approach, and it certainly gets the job done. I don't think any single thing I have called out is more than a nit, but I definitely do think there needs to be more comments throughout.
Thanks for jumping on this!
| FilteredCommand(Microsoft.Terminal.Settings.Model.Command command); | ||
|
|
||
| Microsoft.Terminal.Settings.Model.Command Command { get; }; | ||
| String Filter; |
There was a problem hiding this comment.
Does Filter really need to be exposed in the idl here? I think that could probably just stay as a private member of FilteredCommand
There was a problem hiding this comment.
It is not required for the current implementation. I left this as this is "FilteredCommand", and I assumed that the interface consumers might be interested in both the Command and the Filter. I suggest to leave it, but please let me know if you think otherwise.
| // | ||
| // E.g., ("CL", true) ("ose ", false), ("T", true), ("ab", false), ("S", true), ("after this", false) | ||
| // | ||
| // TODO: we probably need to merge this logic with _getWeight computation? |
There was a problem hiding this comment.
I'm okay with leaving this as a future TODO. I know Dustin L. Howett (@DHowett) has some ideas about _getWeight returning a list of match ranges, as well as the weight. I think for now, this is probably okay as-is though - it's not like iterating twice (O(m*n) for m strings of lengths n) over the strings in the command palette is going to be a bottleneck.
Mind filing a GitHub issue to track consolidating this logic, and linking it here in the code like so?
| // TODO: we probably need to merge this logic with _getWeight computation? | |
| // TODO GH#12345: we probably need to merge this logic with _getWeight computation |
There was a problem hiding this comment.
Mike Griese (@zadjii-msft) - it is actually O(m+n) - we either advance in the filter or in the name. But we definitely should not do it twice, not because of the performance, but rather because of consistency. I will try to unify the logic. If it somehow becomes complex I will open a followup task.
There was a problem hiding this comment.
Mike Griese (@zadjii-msft) - I modified the weight computation logic to use the result of segments computation and moved everything related to filtering and comparison out of CommandPalette into FilteredCommand. Hope this is aligned with Dustin L. Howett (@DHowett) 's vision.
Actually I tried to replace everything related to sorting and filtering out of code-behind, using CollectionViewSource, to discover it is only partially supported in WinRT. So I parked there. But I believe we can create an advanced CollectionViewSource of our own or to use one from the toolkits (if this is considered appropriate) for further cleanup of the CommandPalette.
|
Dustin L. Howett (@DHowett) , Mike Griese (@zadjii-msft) - I don't want to bother here, and somehow "toggle your focus" from the great stuff you are pushing into the product. I just want to raise a concern that since the change set is relatively large, there are conflicts from time to time (until now there were only few but I am worried the number might grow 😄) I will definitely continue back-merging, just bumping this one 😄 |
Dustin L. Howett (DHowett)
left a comment
There was a problem hiding this comment.
I really, really love this. Especially the fact that it's now tested. This is really excellent work, I've just got a couple questions. 😄
| segments.Append(*highlightedSegment); | ||
| } | ||
|
|
||
| return *winrt::make_self<HighlightedText>(segments); |
There was a problem hiding this comment.
| return *winrt::make_self<HighlightedText>(segments); | |
| return winrt::make<HighlightedText>(segments); |
make_self returns a com_ptr that you need to convert to a projected type; make just returns a projected type directly!
There was a problem hiding this comment.
My bad. There are some more places, will fix everywhere. Thanks!
There was a problem hiding this comment.
It’s subtle and likely doesn’t cause any trouble 😄 you just generally use the self version when you need direct access to the implementation namespace type
| { | ||
| if (const auto selectedItem = _filteredActionsView().SelectedItem()) | ||
| const auto& selectedCommand = _filteredActionsView().SelectedItem(); | ||
| if (const auto& filteredCommand = selectedCommand.try_as<winrt::TerminalApp::FilteredCommand>()) |
There was a problem hiding this comment.
i think these have to be const auto instead of const auto&. We can't promise that the projected type reference returned from try_as is going to be "alive" in any meaningful sense of the word. (here and below)
This might work today, but I'm not sure about its legality in C++. Usually you only see const auto& in a ranged for or a parameter.
If there's a C++ person about, they may know better.
There was a problem hiding this comment.
I am changing this in all other places (that were there before my change) to be consistent.
| auto nestedFilteredCommand = winrt::make_self<FilteredCommand>(action); | ||
| _currentNestedCommands.Append(*nestedFilteredCommand); |
There was a problem hiding this comment.
you can likely use make<FilteredCommand> instead of make_self and avoid the dereference on 511
| auto filteredCommand = winrt::make_self<FilteredCommand>(action); | ||
| vectorToPopulate.Append(*filteredCommand); |
| void CommandPalette::_populateFilteredActions(Collections::IVector<winrt::TerminalApp::FilteredCommand> const& vectorToPopulate, Collections::IVector<Command> const& actions) | ||
| { | ||
| vectorToPopulate.Clear(); | ||
| for (const auto action : actions) |
There was a problem hiding this comment.
| for (const auto action : actions) | |
| for (const auto& action : actions) |
this one is safe 😄
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| mc:Ignorable="d" | ||
| Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> |
There was a problem hiding this comment.
Hmm. This one gets me -- should we force the color here or make it transparent? Should we actually template this control and offer a Background binding?
There was a problem hiding this comment.
(Easiest is to make it transparent)
There was a problem hiding this comment.
Absolutely! Thanks!
Dustin L. Howett (DHowett)
left a comment
There was a problem hiding this comment.
Upgrading my status to Red so it comes back around for review 😄
|
Dustin L. Howett (@DHowett) - thanks for the feedback! I hopefully addressed the comments and added some more tests. Please review. In additional my local TabTests are currently failing with access violation, which seems to be related to #8153: I guess works not really good with I create a PR fixing this: #8168 |
Dustin L. Howett (DHowett)
left a comment
There was a problem hiding this comment.
I love this. Thanks so much.
|
🎉 Handy links: |
Summary of the Pull Request
References
PR Checklist
Detailed Description of the Pull Request / Additional comments
Please be gentle - didn't touch XAML and C++ for 8 years 👼
Validation Steps Performed