Add Space key to toggle breakpoint checkboxes in breakpoints view (#313972)

* Initial plan

* Add Space key toggle for breakpoint checkboxes in breakpoints view

Registers a ViewAction with a Space keybinding in the breakpoints view
that toggles the enabled/disabled state of the focused breakpoint item,
including exception breakpoints, function breakpoints, data breakpoints,
and instruction breakpoints.

Fixes #248755

Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/017a281d-da6c-486e-9a18-238acff2ab20

Co-authored-by: roblourens <323878+roblourens@users.noreply.github.com>

* Handle Space key on tree onKeyDown instead of action registration

Instead of registering a ViewAction for the Space keybinding,
handle the keyboard event directly on the tree's onKeyDown event
to toggle the enable/disable state of the focused breakpoint.

Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/28a72182-dfb3-4327-8349-d1cc38cbbf71

Co-authored-by: roblourens <323878+roblourens@users.noreply.github.com>

* Guard Space toggle against editable elements and modifier keys

Use event.equals(KeyCode.Space) instead of checking keyCode directly
so modified-Space combinations (Ctrl+Space, etc.) don't trigger toggle.
Add dom.isEditableElement guard so Space still inserts a space character
when editing breakpoint conditions/names in the inline InputBox.

Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/ba70e0fd-63e2-40bf-8883-9ddddc9a9438

Co-authored-by: roblourens <323878+roblourens@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: roblourens <323878+roblourens@users.noreply.github.com>
This commit is contained in:
Copilot
2026-05-03 12:53:16 -07:00
committed by GitHub
parent cc64b1874e
commit bedd833d89

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as dom from '../../../../base/browser/dom.js';
import { IKeyboardEvent } from '../../../../base/browser/keyboardEvent.js';
import { IKeyboardEvent, StandardKeyboardEvent } from '../../../../base/browser/keyboardEvent.js';
import { ActionBar } from '../../../../base/browser/ui/actionbar/actionbar.js';
import { AriaRole } from '../../../../base/browser/ui/aria/aria.js';
import { getDefaultHoverDelegate } from '../../../../base/browser/ui/hover/hoverDelegateFactory.js';
@@ -278,6 +278,21 @@ export class BreakpointsView extends ViewPane {
}
}));
this._register(this.tree.onKeyDown(e => {
const event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Space) && !dom.isEditableElement(e.target as HTMLElement)) {
const focused = this.tree.getFocus();
if (focused.length > 0) {
const element = focused[0];
if (element && !(element instanceof BreakpointsFolderItem)) {
this.debugService.enableOrDisableBreakpoints(!element.enabled, element);
event.preventDefault();
event.stopPropagation();
}
}
}
}));
// Track collapsed state and update size (items are expanded by default)
this._register(this.tree.onDidChangeCollapseState(e => {
const element = e.node.element;