未验证 提交 6f137556 编写于 作者: I Isidor Nikolic 提交者: GitHub

Merge pull request #79065 from mayaswrath/issues/77879

Issues/77879
......@@ -35,21 +35,23 @@ class ToggleBreakpointAction extends EditorAction {
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<any> {
if (editor.hasModel() && editor.getSelections()) {
const debugService = accessor.get(IDebugService);
const position = editor.getPosition();
if (editor.hasModel() && position) {
const modelUri = editor.getModel().uri;
const bps = debugService.getModel().getBreakpoints({ lineNumber: position.lineNumber, uri: modelUri });
const canSet = debugService.getConfigurationManager().canSetBreakpointsIn(editor.getModel());
// Does not account for multi line selections, Set to remove multiple cursor on the same line
const lineNumbers = [...new Set(editor.getSelections().map(s => s.getPosition().lineNumber))];
return Promise.all(lineNumbers.map(line => {
const bps = debugService.getModel().getBreakpoints({ lineNumber: line, uri: modelUri });
if (bps.length) {
return Promise.all(bps.map(bp => debugService.removeBreakpoints(bp.getId())));
} else if (canSet) {
return (debugService.addBreakpoints(modelUri, [{ lineNumber: line }], 'debugEditorActions.toggleBreakpointAction'));
} else { //Line where a breakpoint cant be set
return Promise.resolve([]);
}
if (debugService.getConfigurationManager().canSetBreakpointsIn(editor.getModel())) {
return debugService.addBreakpoints(modelUri, [{ lineNumber: position.lineNumber }], 'debugEditorActions.toggleBreakpointAction');
}));
}
}
return Promise.resolve();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册