Remove determineSelection and simplify selection commands for the query history#2356
Merged
robertbrignull merged 3 commits intomainfrom Apr 20, 2023
Merged
Conversation
3 tasks
charisk
approved these changes
Apr 20, 2023
| multiSelect, | ||
| ); | ||
| if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem) { | ||
| if (!this.assertSingleQuery(multiSelect)) { |
Contributor
There was a problem hiding this comment.
Not a problem with your PR but "assert" makes me think an error will be thrown if the expectation isn't met. Perhaps we should rename to isSingleQuery or something like that in the future.
Contributor
Author
There was a problem hiding this comment.
Yes I agree it's confusingly named. I actually plan to delete it entirely in #2287
Contributor
Author
Ooh, I love the chance to delete even more code 🔥 These tests are now gone! I guess this is another case of me not running |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR aims to simplify all our selection commands in the query history manager. The things we do are:
determineSelectionmethod.singleItemshould now always be defined, and there's some description onTreeViewContextMultiSelectionCommandFunctionabout whenmultiSelectis defined or not.TreeViewContextMultiSelectionCommandFunctionsingleItemas possibly-undefined, but this isn't necessary.singleItemis not undefinedsingleItemis undefined or not. If our types are wrong we should change them, but I'm pretty convinced that they're correct.multiSelect ||= [singleItem]in commands where we do operate on multiple itemsmultiSelectbeing undefined when only a single item is selected. Why VS Code gives us the arguments this way is a mystery to me, but that's what it does.multiSelectwas always populated was something thatdetermineSelectiondid, so now there's a couple of places where we need to do that ourselves. This will go away again with Introduce helpers for commands that operate on selections #2287.If I'm correct, then this PR won't change any behaviour. I've done my best to manually test using the hover and right-click actions in every circumstance I could think of, and the rules follow what I wrote on
TreeViewContextMultiSelectionCommandFunction.This PR is another precursor to #2287 and it'll make that PR a lot simpler. In that PR we'll simplify method types again so they take exactly the arguments they need, and we can remove the need for the
assertSingleQuerymethod.Checklist
ready-for-doc-reviewlabel there.