Visual Studio能够记住以前调试会话中的断点,这非常棒。

但是,当我在调试时,通过单击它来清除其中一个“旧”断点时,它只是被暂时删除了。我的意思是,下次调试时,我以为我删除的断点又回来了。

这非常烦人——有没有设置让它不这样做?


当前回答

如果你正在调试一个web应用程序,并在chrome中设置了一个断点,VS code会尊重这个断点,不会让你删除它。换句话说,有效的断点是在VS Code和chrome中设置的断点的总和。是的,有时候很容易忘记你在chrome中设置了一个断点,并迷失在试图弄清楚如何从VS Code中删除它。

其他回答

Start your debug session with a minimal number of files open, as you debug the unwanted breakpoints will show up and the containing files will open in new tabs. Terminate the debug session and open the breakpoints window (from the debug toolbar, for some reason it is not in the view menu). For each file, enter the name of the file in the search area of the breakpoints window and press enter to filter out the breakpoints by file. You can then click on each breakpoint in the window to see where they are located in the code and delete them if you want. A bit tedious but that the best way I found to get rid of those unwanted ghost breakpoints... Bookmarks and breakpoints management.. Those functions were probably last enhanced sometime during the last century...

如果你正在调试一个web应用程序,并在chrome中设置了一个断点,VS code会尊重这个断点,不会让你删除它。换句话说,有效的断点是在VS Code和chrome中设置的断点的总和。是的,有时候很容易忘记你在chrome中设置了一个断点,并迷失在试图弄清楚如何从VS Code中删除它。

这里有一些答案,但在我看来,在调试期间使用建议的操作会分散注意力(我不想失去我的注意力)。

我在断点期间使用粘断点的流程如下:

在调试期间,禁用断点,而不是删除它。

禁用断点的可能方法:

鼠标悬停,点击两个循环图标; 或者使用上下文菜单; 或键盘快捷键CTRL+F9(不是Shift+CTRL+F9,因为它清除所有断点)。

稍后,在开发过程中,当我看到一个禁用的断点时,我会删除它。

PS.偶尔删除所有断点也是一个很好的实践。

用Visual Studio 2017快速回答这个老问题。

如果可能的话,只需剪切并粘贴带有断点的代码。断点随着切割而消失。

在Vscode的新版本中,它被称为:Remove all Breakpoints

Vscode版:

Version: 1.57.1
Commit: 507ce72a4466fbb27b715c3722558bb15afa9f48
Date: 2021-06-17T13:28:32.912Z (1 wk ago)