当我在调试时"全部打破"时,Visual Studio会在堆栈顶部打开源代码; 我想将光标放在我正在处理的文档上,而不打开任何其他文档或窗口(例如:没有加载符号).
Ale*_*ici 10
有一种方法可以保留当前文档,但这需要在" 调试"工具栏中创建Visual Studio加载项和新的UI命令.这个答案的积分实际上也应该是 openshac,他发布了类似的SO 问题,并通过使用宏在他的OP中给出了解决方法.
实现相当简单(我花了几分钟才能使它工作).首先,在加载项项目中,修改文件中的Exec方法,Connect.cs如下所示:
public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
handled = false;
if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if(commandName == "BreakInCurrentDocument.Connect.BreakInCurrentDocument")
{
// here's where the magic happens
// ******************************
var activeWindow = _applicationObject.ActiveWindow;
_applicationObject.Debugger.Break();
if (_applicationObject.ActiveWindow != activeWindow)
{
_applicationObject.ActiveWindow.Close(vsSaveChanges.vsSaveChangesNo);
}
// ******************************
handled = true;
return;
}
}
}
Run Code Online (Sandbox Code Playgroud)
创建并注册加载项后,只需:
而已.
Jar*_*das 10
最新版本的VSCommands扩展(免费版)可从http://visualstudiogallery.msdn.microsoft.com/a83505c6-77b3-44a6-b53b-73d77cba84c8获得,这正是您想要的.它在Debug Toolbar和Debug Menu中添加了一个Break In Current Document按钮:
http://vscommands.squaredinfinity.com/Media/VSCommands/BlogPost//blog/breakincurrentdocument.png
| 归档时间: |
|
| 查看次数: |
1911 次 |
| 最近记录: |