You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the last milestone we've added API to make the set of breakpoints registered with VS Code available to extensions. In this milestone we've added more API for adding and removing breakpoints programmatically.
Here is the new API (available only in vscode.proposed.d.ts):
export namespacedebug{/** * Add breakpoints. * @param breakpoints The breakpoints to add. */exportfunctionaddBreakpoints(breakpoints: Breakpoint[]): void;/** * Remove breakpoints. * @param breakpoints The breakpoints to remove. */exportfunctionremoveBreakpoints(breakpoints: Breakpoint[]): void;}/** * A breakpoint specified by a source location. */exportclassSourceBreakpointextendsBreakpoint{//.../** * Create a new breakpoint for a source location. */constructor(location: Location,enabled?: boolean,condition?: string,hitCondition?: string);}/** * A breakpoint specified by a function name. */exportclassFunctionBreakpointextendsBreakpoint{//.../** * Create a new function breakpoint. */constructor(functionName: string,enabled?: boolean,condition?: string,hitCondition?: string);}
Verify that this API works as expected.
Here is some starter code that adds two context menu actions for adding and removing breakpoints for multiple lines:
'use strict';import*asvscodefrom'vscode';exportfunctionactivate(context: vscode.ExtensionContext){vscode.debug.onDidChangeBreakpoints(e=>{console.log(`Event: a: ${e.added.length} r: ${e.removed.length} c: ${e.changed.length}`);/* if (e.added.length) console.log('added: ', JSON.stringify(e.added)); if (e.removed.length) console.log('removed: ', JSON.stringify(e.removed)); if (e.changed.length) console.log('changed: ', JSON.stringify(e.changed)); console.log('breakpoints after event: ', JSON.stringify(vscode.debug.breakpoints)); */});context.subscriptions.push(vscode.commands.registerCommand('extension.addBreakpoint',()=>{leteditor=vscode.window.activeTextEditor;if(editor){letdocument=editor.document;letselections=editor.selections;constcolumn=selections[0].end.character;constbps: vscode.Breakpoint[]=[];for(letline=selections[0].start.line;line<=selections[0].end.line;line++){bps.push(newvscode.SourceBreakpoint(newvscode.Location(document.uri,newvscode.Position(line,column))));}vscode.debug.addBreakpoints(bps);}else{vscode.window.showInformationMessage('Open a file first to manipulate text selections');}}));context.subscriptions.push(vscode.commands.registerCommand('extension.removeBreakpoint',()=>{leteditor=vscode.window.activeTextEditor;if(editor){letdocument=editor.document;letselection=editor.selections[0];constfound=vscode.debug.breakpoints.filter(bp=>{if(bpinstanceofvscode.SourceBreakpoint){constbpline=bp.location.range.start.line;returnbp.location.uri.toString()===document.uri.toString()&&bpline>=selection.start.line&&bpline<=selection.end.line;}returnfalse;});vscode.debug.removeBreakpoints(found);}else{vscode.window.showInformationMessage('Open a file first to manipulate text selections');}}));}exportfunctiondeactivate(){}
and the corresponding sections from the package.json:
Test for #42173:
Complexity: 3
In the last milestone we've added API to make the set of breakpoints registered with VS Code available to extensions. In this milestone we've added more API for adding and removing breakpoints programmatically.
Here is the new API (available only in vscode.proposed.d.ts):
Verify that this API works as expected.
Here is some starter code that adds two context menu actions for adding and removing breakpoints for multiple lines:
and the corresponding sections from the package.json:
The text was updated successfully, but these errors were encountered: