有没有办法留在当前文档时"打破所有的"在Visual Studio 2012? [英] Is there a way to stay on current document when "breaking all" in Visual Studio 2012?

查看:160
本文介绍了有没有办法留在当前文档时"打破所有的"在Visual Studio 2012?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio中打开源代码的堆栈的顶部,当我打破了所有在调试;我想保持我目前工作的文件光标,没有任何其他文件或窗口(例如:在没有装载符号)被打开

Visual Studio opens source code on top of the stack when I break all while debugging; I want to keep the cursor on the document I'm currently working on, without any other document or windows (e.g.: no symbols loaded) being opened.

推荐答案

有是留在当前文档的方式,但是这需要创建一个Visual Studio插件和的调试的工具栏上的一个新的UI命令。对于这个答案信用证应居然还去 openshac ,谁发布了类似的SO的问题并且还通过使用宏给了他一个OP解决办法。

There is a way to stay on the current document, but that requires creating a Visual Studio add-in and a new UI command in the Debug toolbar. Credits for this answer should actually also go to openshac, who posted a similar SO question and also gave a workaround in his OP by using a macro.

的实施是相当简单的(我花了几分钟,有工作)。首先,在外接项目,修改 Connect.cs 文件中像这样的 Exec的方法:

The implementation is fairly simple (it took me a few minutes to have it working). First, in the add-in project, modify the Exec method in the Connect.cs file like this:

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;
        }
    }
}



创建和注册的加载后-in,只是:

After creating and registering the add-in, just:


  1. 点击工具的Visual Studio的菜单上

  2. 自定义

  3. 命令

  4. 选择工具栏单选按钮

  5. 选择调试

  6. 添加命令...

  7. 从加载项类别中,选择您的自定义插件。

  1. click TOOLS on the Visual Studio's menu
  2. Customize
  3. Commands
  4. Choose the "Toolbar" radio button
  5. Select "Debug"
  6. Add Command...
  7. From the "Addins" category, choose your custom add-in.

这就是它。

这篇关于有没有办法留在当前文档时"打破所有的"在Visual Studio 2012?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆