Skip to content

Conversation

@obrobrio2000
Copy link
Contributor

@obrobrio2000 obrobrio2000 commented Oct 2, 2025

Fixes #258967
Related to #258961

Description

Adds navigation buttons and keyboard shortcuts to jump between uncovered lines in the test coverage view.

Changes

  • New Commands:

    • testing.coverage.goToNextMissedLine (Alt+F9)
    • testing.coverage.goToPreviousMissedLine (Shift+Alt+F9)
  • UI Enhancements:

    • Added up/down arrow buttons to the Coverage Toolbar Widget
    • Added menu items in Editor Title when coverage is active
    • Commands available in Command Palette when coverage is open
  • Navigation Behavior:

    • Jumps to next/previous line with zero test coverage
    • Wraps around at file boundaries for continuous navigation
    • Centers the target line in the editor for better visibility
    • Only enabled when coverage data is available for the current file

Implementation Details

The implementation follows VS Code's existing navigation patterns (similar to "Go to Next Error"):

  • Navigation methods in CodeCoverageDecorations class iterate through decorations marked with CLASS_MISS
  • Action2 classes provide command registration with keybindings and menu integration
  • Toolbar buttons execute the commands via ICommandService

Testing

To test:

  1. Open a file with test coverage
  2. Use Alt+F9 to jump to next uncovered line
  3. Use Shift+Alt+F9 to jump to previous uncovered line
  4. Verify navigation wraps around at file boundaries
  5. Check toolbar buttons appear and function correctly
Implements [microsoft#258967](https://github.com/obrobrio2000/vscode/issues/258967)

- Add commands to navigate to next/previous uncovered lines
- Add navigation buttons to coverage toolbar widget
- Add keyboard shortcuts (Alt+F9 / Shift+Alt+F9)
- Navigation wraps around at file boundaries
- Buttons appear in coverage toolbar and editor title menu

This feature helps developers efficiently review coverage gaps
by allowing them to jump between uncovered lines without manual
scrolling through the file.

Signed-off-by: Giovanni Magliocchetti <giovimag123@gmail.com>
Copilot AI review requested due to automatic review settings October 2, 2025 09:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds keyboard shortcuts and UI navigation buttons to jump between uncovered lines in VS Code's test coverage view, making it easier for developers to navigate through untested code sections.

  • Adds two new commands for navigating to next/previous uncovered lines with Alt+F9 and Shift+Alt+F9 keybindings
  • Implements navigation logic in the CodeCoverageDecorations class to find and jump to missed coverage lines
  • Adds up/down arrow buttons to the coverage toolbar widget for UI-based navigation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/vs/workbench/contrib/testing/common/constants.ts Adds command IDs for the new navigation commands
src/vs/workbench/contrib/testing/browser/codeCoverageDecorations.ts Implements navigation methods and registers Action2 commands with keybindings and menu items
obrobrio2000 and others added 2 commits October 2, 2025 11:47
…ns.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Add proper sorting of missed lines by line number
- Fix corrupted control flow in previous/back navigation
- Add missing variable declarations
- Remove duplicate/incorrect conditional blocks

This fixes the navigation to work correctly with properly
ordered missed lines.

Signed-off-by: Giovanni Magliocchetti <giovimag123@gmail.com>
Signed-off-by: Giovanni Magliocchetti <giovimag123@gmail.com>
connor4312
connor4312 previously approved these changes Oct 3, 2025
Copy link
Member

@connor4312 connor4312 left a comment

Choose a reason for hiding this comment

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

lgtm thanks!

@connor4312 connor4312 enabled auto-merge (squash) October 3, 2025 15:21
@vs-code-engineering vs-code-engineering bot added this to the October 2025 milestone Oct 3, 2025
lramos15
lramos15 previously approved these changes Oct 3, 2025
@connor4312
Copy link
Member

There are some compile errors:

Error: [define-class-fields-check] src/vs/workbench/contrib/testing/browser/codeCoverageDecorations.ts(268,10): error TS6133: 'isMissedLine' is declared but its value is never read.
Error: [define-class-fields-check] src/vs/workbench/contrib/testing/browser/codeCoverageDecorations.ts(1040,102): error TS2339: Property 'ID' does not exist on type 'typeof CodeCoverageDecorations'.
Error: [define-class-fields-check] src/vs/workbench/contrib/testing/browser/codeCoverageDecorations.ts(1076,102): error TS2339: Property 'ID' does not exist on type 'typeof CodeCoverageDecorations'.
- Add static ID property to CodeCoverageDecorations class
- Remove unused isMissedLine method (logic handled inline)
- Fixes TypeScript compilation errors

Signed-off-by: Giovanni Magliocchetti <giovimag123@gmail.com>
auto-merge was automatically disabled October 3, 2025 17:06

Head branch was pushed to by a user without write access

@obrobrio2000 obrobrio2000 dismissed stale reviews from lramos15 and connor4312 via f33d35e October 3, 2025 17:06
const BRANCH_MISS_INDICATOR_CHARS = 4;

export class CodeCoverageDecorations extends Disposable implements IEditorContribution {
public static readonly ID = 'editor.contrib.coverageDecorations';
Copy link
Member

Choose a reason for hiding this comment

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

This is already available via the constants enum Testing.CoverageDecorationsContributionId

Signed-off-by: Giovanni Magliocchetti <giovimag123@gmail.com>
@connor4312
Copy link
Member

connor4312 commented Oct 3, 2025

Still some errors -- these should be shown in your vscode window if you have the eslint extension installed:

Warning: [eslint ] [21:59:56] /mnt/vss/_work/vscode/vscode/src/vs/workbench/contrib/testing/browser/codeCoverageDecorations.ts: line 1006, col 11, Warning - Duplicate key 'testing.goToNextMissedLine' with different message value. (local/code-no-unexternalized-strings)
Warning: [eslint ] /mnt/vss/_work/vscode/vscode/src/vs/workbench/contrib/testing/browser/codeCoverageDecorations.ts: line 1042, col 11, Warning - Duplicate key 'testing.goToPreviousMissedLine' with different message value. (local/code-no-unexternalized-strings)
[eslint ]
[e

Signed-off-by: Giovanni Magliocchetti <giovimag123@gmail.com>
@connor4312 connor4312 enabled auto-merge (squash) October 6, 2025 18:32
@connor4312 connor4312 merged commit 98dd604 into microsoft:main Oct 6, 2025
17 checks passed
@benvillalobos benvillalobos added verified Verification succeeded and removed verified Verification succeeded labels Nov 5, 2025
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Nov 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

5 participants