开发者

Visual studio 2010: limiting the number of editor tabs

开发者 https://www.devze.com 2023-04-08 00:49 出处:网络
Visual studio doesn\'t appear to limit the number of opened editor tabs. I\'m using ReSharper and at a certain number of opened edi开发者_如何学JAVAtor tabs things get really slow. So I have to keep t

Visual studio doesn't appear to limit the number of opened editor tabs. I'm using ReSharper and at a certain number of opened edi开发者_如何学JAVAtor 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?


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号