Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

F4 would continue navigating references even when the search view was focused. Both keybindings' when clauses could be true simultaneously, causing the wrong command to execute.

Changes

Added focusedView context to the references-view keybinding to ensure it only activates when the references view is focused:

references-view (extensions/references-view/package.json):

  • F4/Shift+F4 now require focusedView == 'references-view.tree'

This allows the search keybinding to take precedence when the search view is focused, fixing the reported conflict.

Example

Before: Both conditions active → references wins

// references-view: "when": "reference-list.hasResult"
// search: "when": "hasSearchResult || inSearchEditor"

After: View focus determines priority

// references-view: "when": "reference-list.hasResult && focusedView == 'references-view.tree'"
// search: "when": "hasSearchResult || inSearchEditor" (unchanged)

Testing

  • ✅ TypeScript compilation passes
  • ✅ Only references-view extension modified as requested
  • ✅ References navigation now requires the references view to be focused
  • ✅ Search navigation takes precedence when search view is focused
Original prompt

This section details on the original issue you should resolve

<issue_title>Next Reference and Next Search Result Conflict</issue_title>
<issue_description>
Type: Bug

  1. Open any folder where the programming language supports 'find all references'. I have tried python and c++ projects
  2. Use the search feature (Ctrl + Shift + F)
  3. Observe that pressing F4 cycles through the search results
  4. Use the 'find all references' feature on a source code symbol
  5. Overserve that pressing F4 cycles through the reference results
  6. Use the search feature again
  7. Observe that pressing F4 reopens the references panel and cycles references instead of search results (the currently active panel)

** Expected Result **
F4 key goes to the next item on the current panel (whether it be references or search results).

** Other Details **
I have tried this on insiders edition with only the minimum extensions required to use the 'find all references' feature.

** Hotkey Mapping **
137: { "key": "f4", "command": "references-view.next",
"when": "reference-list.hasResult && references-view.canNavigate" },
...
1141: { "key": "f4", "command": "search.action.focusNextSearchResult",
"when": "hasSearchResult || inSearchEditor" },

VS Code version: Code 1.96.2 (fabdb6a, 2024-12-19T10:22:47.216Z)
OS version: Windows_NT x64 10.0.22631
Modes:

System Info
Item Value
CPUs 13th Gen Intel(R) Core(TM) i9-13900K (32 x 2995)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 95.75GB (65.36GB free)
Process Argv --crash-reporter-id 28a27f36-60c5-4553-bd3f-bc1be676f0c5
Screen Reader no
VM 0%
Extensions (30)
Extension Author (truncated) Version
ruff cha 2024.56.0
continue Con 0.8.66
dart-code Dar 3.102.0
flutter Dar 3.102.0
vscode-eslint dba 3.0.10
githistory don 0.6.20
gitlab-workflow Git 5.25.1
vscode-clangd llv 0.1.33
git-graph mhu 1.30.0
debugpy ms- 2024.14.0
python ms- 2024.22.2
vscode-pylance ms- 2024.12.1
cmake-tools ms- 1.19.52
cpptools ms- 1.22.11
cpptools-extension-pack ms- 1.3.0
hexeditor ms- 1.11.1
powershell ms- 2024.4.0
vs-keybindings ms- 0.2.1
vsliveshare ms- 1.0.5948
vscode-yaml red 1.15.0
rust-analyzer rus 0.3.2257
swift-lang ssw 1.11.4
svelte-vscode sve 109.5.1
even-better-toml tam 0.21.2
cmake twx 0.0.17
vscode-lldb vad 1.11.1
vscode-svg-previewer vit 0.7.0
gitblame wad 11.1.1
change-case wma 1.0.0
clang-format xav 1.9.0

(5 theme extensions excluded)

A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
962ge761:30959799
pythonnoceb:30805159
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupytercf:31046870
2f103344:31071589
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc1:31192215
cf971741:31144450
iacca1:31171482
notype1:31157159
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624

<agent_instructions>Do as suggested in the last comment</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 8, 2025 09:52
Add focusedView context to F4/Shift+F4 keybindings for both search and references-view to ensure the focused view takes priority. This fixes the issue where F4 would continue navigating references even when the search view was focused.

- Updated references-view keybindings to require focusedView == 'references-view.tree'
- Updated search action keybindings to require focusedView == 'workbench.view.search'

Co-authored-by: jrieken <1794099+jrieken@users.noreply.github.com>
Extract the duplicate SearchNavigationKeybindingWhen condition into a shared constant to reduce code duplication and improve maintainability.

Co-authored-by: jrieken <1794099+jrieken@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix F4 key cycling through search and reference results Fix F4 keybinding conflict between search and references navigation Dec 8, 2025
Copilot AI requested a review from jrieken December 8, 2025 10:02
Copilot finished work on behalf of jrieken December 8, 2025 10:02
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change anything in this file. Only changes into references-view are allowed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted all changes to searchActionsNav.ts in commit 1cd588f. Only the references-view/package.json file is now modified, which adds the focusedView context check to ensure F4 only navigates references when that view is focused.

As requested by @jrieken, removed all changes to searchActionsNav.ts. Only keeping the changes to references-view/package.json which adds focusedView context to the F4 keybindings.

Co-authored-by: jrieken <1794099+jrieken@users.noreply.github.com>
Copilot AI requested a review from jrieken December 8, 2025 11:00
Copilot finished work on behalf of jrieken December 8, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Next Reference and Next Search Result Conflict

2 participants