Visual studio 2010: limiting the number of editor tabs

牧云@^-^@ 提交于 2019-12-22 10:27:26

问题


Visual studio doesn't appear to limit the number of opened editor tabs. I'm using ReSharper and at a certain number of opened editor tabs things get really slow. So I have to keep track of opened tabs and periodically close old ones. It would be cool if I could set a limit so that it would close old tabs when the limit is reached.

Is there a setting in VS / ReSharper or any VS addons that can help to achieve this?


回答1:


I'm trying to solve this with a primitive addin at the moment. Seems to be working fine. Still testing it.

    public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
    {

        _applicationObject = (DTE2)application;

        _applicationObject.Events.WindowEvents.WindowCreated += 
        window =>
        {
            if (window.Document != null)
            {
                documentWindows.AddFirst(window);
                if(documentWindows.Count > 7)
                {
                    Window lastWindow = documentWindows.Last.Value;
                    documentWindows.Remove(lastWindow);
                    lastWindow.Close(vsSaveChanges.vsSaveChangesYes);
                }
            }
        };

        _applicationObject.Events.WindowEvents.WindowClosing +=
            window =>
                {
                if(window.Document != null)
                {
                    documentWindows.Remove(window);
                }
                };
    }


来源:https://stackoverflow.com/questions/7581448/visual-studio-2010-limiting-the-number-of-editor-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!