Add editor context menu support for Razor nested file commands#13023
Merged
Add editor context menu support for Razor nested file commands#13023
Conversation
Finishes work for https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1903761 Earlier PRs in support of this ticket: #12981 https://devdiv.visualstudio.com/DevDiv/_git/WebTools/pullrequest/725194 https://devdiv.visualstudio.com/DevDiv/_git/WebTools/pullrequest/725955 Add editor context menu commands for Razor nested files alongside the existing Solution Explorer commands. Uses VSCT CommandPlacements to share CSS/JS command IDs across both menus, and IVsMonitorSelection.GetCurrentSelection to resolve the active file (which tracks the active window frame, not just Solution Explorer tree selection). Key changes: - Unified NestedFileCommandHandler serves both Solution Explorer and editor menus via shared command IDs and SelectionHelper for selection/UIContext queries - Added editor context menu group (grpidRazorNestedFilesEditor) on IDM_VS_CTXT_CODEWIN with CSS/JS commands placed via CommandPlacements - For .cs in editor: intercept standard ViewCode (F7) command via UsedCommands so the F7 keybinding indicator displays automatically. Handler yields (Supported=false) to fall through to default ViewCode when not in a Razor file - Added separate cmdidAddNestedCsFileEditor for the "Add .cs" case in editor, so it appears without the F7 keybinding when the .cs file doesn't exist - Added "View Page" command for navigating from nested files back to the parent Razor file, placed in editor, Solution Explorer, and CSS editor context menus - Extended UIContextRule to activate for nested files (.razor.* and .cshtml.*) in addition to .razor and .cshtml - ViewCodeCommandHandler (MEF F7 handler): returns Unavailable when .cs doesn't exist, excludes _Imports.razor and _ViewImports.cshtml, uses FileExistsHelper cache for per-keystroke performance - Added View_Page resource with translations, cleaned up unused Add_Code resource - Updated tests for new constructor signature and behavior
davidwengier
approved these changes
Apr 9, 2026
Member
davidwengier
left a comment
There was a problem hiding this comment.
Some screenshots would be good, as we might be able to use them in release notes etc
| NestedFileKind fileKind, | ||
| Lazy<LSPRequestInvokerWrapper> requestInvoker) | ||
| Lazy<LSPRequestInvokerWrapper> requestInvoker, | ||
| bool allowExternalHandlers = false, |
Member
There was a problem hiding this comment.
Not: I'd prefer to avoid optional parameters on internal code if it's not a big pain
Contributor
Author
This was referenced Apr 9, 2026
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.


Finishes work for https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1903761 Earlier PRs in support of this ticket:
#12981
https://devdiv.visualstudio.com/DevDiv/_git/WebTools/pullrequest/725194
https://devdiv.visualstudio.com/DevDiv/_git/WebTools/pullrequest/725955
Add editor context menu commands for Razor nested files alongside the existing Solution Explorer commands. Uses VSCT CommandPlacements to share CSS/JS command IDs across both menus, and IVsMonitorSelection.GetCurrentSelection to resolve the active file (which tracks the active window frame, not just Solution Explorer tree selection).
Key changes: