Repository navigation
[VS] Code Search: preview for X# results, the preview no longer takes the focus - #2171
Merged
RobertvanderHulst merged 2 commits intoNov 11, 2026
Merged
Conversation
DropDownClient.InitCaret sends the focus to every new view of a file that is already open in an editor. The preview editor of the Code Search (Ctrl+T) is such a view, so the keys typed for the search changed the code. Views with the role SEARCH_RESULT_PREVIEW are left alone now. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The X# source of the Code Search returns a preview panel: the file in the editor of the search window, at the declaration, as C# has it. CodeEditorModel is created by reflection: Microsoft.VisualStudio.Search is built against the Microsoft.VisualStudio.Threading of its own Visual Studio, newer than the one of the SDK package (CS1705 on AsyncLazy). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Summary
Two changes for the Code Search window (Ctrl+T) of VS 2022 17.6+ and VS 2026.
1. The preview no longer takes the focus (bug fix)
When the file of the selected result was already open in an editor, the focus jumped from the search box into the preview editor a moment after the window opened. The next keys typed for the search then changed the code.
XSharpDropDownClient.InitCaretcallsSendExplicitFocus()on every new view of a file whose drop-down client already has an active view. The preview editor of the Code Search is such a view.addTextViewskips that step for views with the roleSEARCH_RESULT_PREVIEW. All other views behave as before.f:) and text (x:) results of VS itself, which preview.prgfiles in the same editor.2. Preview for X# results
The X# source (
XSharpSearchItemsSourceProvider) returned no preview panels, so the lower half of the window said "There is nothing to preview at the moment". It now returns a panel that shows the file at the declaration, in the editor of the search window, as C# does.CodeEditorModelis created by reflection.Microsoft.VisualStudio.Search.dllis built against theMicrosoft.VisualStudio.Threadingof its own Visual Studio (17.14 here), newer than the one of our SDK package (17.10), and the compiler refuses theAsyncLazy<TextDocumentLocation>parameter with CS1705.Guid.Empty), as the file search of VS does: a file may be in several projects.Test plan
ProjectPackage2022builds (Debug)CpsTestBed.sln: select a method name in an open.prg, Ctrl+T, keep typing. The focus stays in the search box and the preview shows the declaration. Before the fix the typed text went into the preview editor.🤖 Generated with Claude Code