Fix getCurrentQuery to look at active tabs instead of active text editors
#2685
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.
The
getCurrentQuerymethod determines the "active" query by checking the VS CodeactiveTextEditor. Due to how VS Code defines text editors, this leads to weird cases where it can consider comment/discussion boxes as the active text editor, instead of the underlying file 😅 E.g. we have a bug in the CodeQL code tour, where we accidentally set this comment as the active editor.🔗 See internal linked issue for more details!
To avoid this, we can look at the active editor tab instead. This doesn't change the existing behaviour, and fixes the weird comment/discussion box bug. I've tested this in various cases, including running quick eval, quick queries, and just running queries from various places (context menu, file explorer, command palette) 😄
Note that there are some other places in the code where we use
window.activeTextEditor. We could change all of those occurrences, but I'm hesitant to overcomplicate things where it's probably not necessary 🙈👀
@dbartol, would you mind giving this a quick look/test? The bug first occured after 0bd0bf1 and the
getCurrentQuerymethod is also used in the new debugger here. I want to be sure that the "save dirty documents" and debugging stuff all still works as expected too!Checklist
I'm not sure this needs a changelog entry, since it doesn't change any behaviour? 🤔 (and the codespace template/code tour is still in beta)
ready-for-doc-reviewlabel there.