选项卡关闭时如何在VS2013中禁用MRU行为 [英] How to disable MRU behavior in VS2013 upon tab close
问题描述
我已经将ctl + tab和ctl + shift + tab映射到Window.NextTab和Window.PreviousTab.
I have already remapped ctl+tab and ctl+shift+tab to Window.NextTab and Window.PreviousTab.
但是当我调用File.Close时,Visual Studio 2013仍使用MRU来确定将哪个选项卡带到前台,这通常会导致焦点跳到未指向的某个位置.我想更改此行为,以便将刚关闭的选项卡(位于选项卡右侧)之后的选项卡带到前台(如果存在).这将使VS的行为与ff,chrome,notepad ++等的行为相匹配.
But when I call File.Close, Visual Studio 2013 still uses MRU to decide which tab to bring to the foreground, which usually results in focus jumping somewhere unepxected. I would like to change this behavior so that the tab right after the just-closed one (to the right in the tab well) is brought to the foreground (if it exists). This would make VS's behavior match that of ff, chrome, notepad++ etc.
我尝试了很多扩展,尽管其中许多扩展更改或创建了自己的下一个/上一个制表符功能,但似乎都没有一个新版本的File.Close.
I've tried a bunch of extensions, and while many of them change or create their own next / previous tab functions, none seems to make a new version of File.Close.
有人知道这是否可行或任何扩展的身份吗?
Does anyone know if this is possible or the identity of any extensions which do it?
推荐答案
您可以使用在 Visual Commander (而不是File).关闭以在关闭后激活下一个选项卡:
You can use the following command created in Visual Commander instead of File.Close to activate next tab after close:
public class C : VisualCommanderExt.ICommand
{
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
dte = DTE;
if (IsCommandAvailable("Window.NextTab"))
{
DTE.ExecuteCommand("Window.NextTab");
DTE.ExecuteCommand("Window.PreviousTab");
}
if (IsCommandAvailable("File.Close"))
DTE.ExecuteCommand("File.Close");
}
private bool IsCommandAvailable(string commandName)
{
EnvDTE80.Commands2 commands = dte.Commands as EnvDTE80.Commands2;
if (commands == null)
return false;
EnvDTE.Command command = commands.Item(commandName, 0);
if (command == null)
return false;
return command.IsAvailable;
}
private EnvDTE80.DTE2 dte;
}
更新一种可能更好的实施方式,可以防止潜在的视觉副作用:
Update A probably better implementation that prevents potential visual side effects:
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
dte = DTE;
if (IsCommandAvailable("Window.NextTab"))
{
EnvDTE.Window w = DTE.ActiveWindow;
DTE.ExecuteCommand("Window.NextTab");
w.Close();
}
else if (IsCommandAvailable("File.Close"))
DTE.ExecuteCommand("File.Close");
}
这篇关于选项卡关闭时如何在VS2013中禁用MRU行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!