Reputation: 6667
I use "Navigate-Declaration" all the time in IntelliJ IDEA. I would like to configure it to behave slightly differently when split editors are used.
The basic use case is simple:
However, things behave strange when using a split window:
If this class is already open in the left side tab group, IntelliJ will bring that tab forward in the left editor, replacing the one class I selected for viewing. However, if the class is not already open in any tab group, IntelliJ will open the file on the right side tab group. This is essentially the same as what happens when a split editor is not used.
Even worse, "Navigate->Back" action will now indeed navigate back to the original class in the right side, but does not change anything on the left side, i.e. that one class that I intended to refer to for a while is not visible.
So the behavior of the "Navigate->Open Declaration" action is dependent on the state of IntelliJ itself, and not on my intention. I do not want intelliJ to arbitrarily decide which split window to show a file in. I would rather that it only open the declaration in the tab group where the cursor curently is.
What would be really nice is an action like "Navigate->open declaration in current tab group". Does this exist? Can a plugin be created for this?
Upvotes: 8
Views: 1530
Reputation: 4054
I have the same issue but I have a workaround that works for most of my cases:
In Settings > Editor > General > Editor Tabs, and under Closing Policy, I set the tab limit to 1. This enforces a single tab per split, which prevents a hidden tab in another split from opening when you navigate to a symbol within it. When you go to declaration, if the destination file is in a split, it will go there, and if it doesn't exist, it will replace the tab in your split. This works for most cases, it might get trickier if you don't want intellij to change the part of the file you're looking at in a split, but for most cases it works.
(Also I don't use tabs generally to remember which files, I usually use the Recent Files window to navigate).
Upvotes: 1