mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-224071 Switcher opens a tab in the previous split when tabs placement is set to none
GitOrigin-RevId: 121013134b24e1a11599ed099d954fc45095df53
This commit is contained in:
committed by
intellij-monorepo-bot
parent
df3c4578ee
commit
594b35802f
@@ -737,6 +737,7 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
final FileEditorManagerImpl editorManager = (FileEditorManagerImpl)FileEditorManager.getInstance(project);
|
||||
final ArrayList<FileInfo> filesData = new ArrayList<>();
|
||||
final ArrayList<FileInfo> editors = new ArrayList<>();
|
||||
LinkedHashSet<VirtualFile> addedFiles = new LinkedHashSet<>();
|
||||
if (!pinned) {
|
||||
for (Pair<VirtualFile, EditorWindow> pair : editorManager.getSelectionHistory()) {
|
||||
editors.add(new FileInfo(pair.first, pair.second, project));
|
||||
@@ -744,7 +745,10 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
}
|
||||
if (editors.size() < 2 || pinned) {
|
||||
if (pinned && editors.size() > 1) {
|
||||
filesData.addAll(editors);
|
||||
for (FileInfo fileInfo : editors) {
|
||||
if (addedFiles.add(fileInfo.first))
|
||||
filesData.add(fileInfo);
|
||||
}
|
||||
}
|
||||
int maxFiles = Math.max(editors.size(), filesForInit.size());
|
||||
int minIndex = pinned ? 0 : (filesForInit.size() - Math.min(toolWindowsCount, maxFiles));
|
||||
@@ -770,20 +774,26 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
}
|
||||
}
|
||||
if (add) {
|
||||
filesData.add(info);
|
||||
if (!firstRecentMarked && !info.first.equals(currentFile)) {
|
||||
selectionIndex = filesData.size() - 1;
|
||||
firstRecentMarked = true;
|
||||
if (addedFiles.add(info.first)) {
|
||||
filesData.add(info);
|
||||
if (!firstRecentMarked && !info.first.equals(currentFile)) {
|
||||
selectionIndex = filesData.size() - 1;
|
||||
firstRecentMarked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//if (editors.size() == 1) selectionIndex++;
|
||||
if (editors.size() == 1 && (filesData.isEmpty() || !editors.get(0).getFirst().equals(filesData.get(0).getFirst()))) {
|
||||
filesData.add(0, editors.get(0));
|
||||
if (addedFiles.add(editors.get(0).first)) {
|
||||
filesData.add(0, editors.get(0));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < Math.min(30, editors.size()); i++) {
|
||||
filesData.add(editors.get(i));
|
||||
if (addedFiles.add(editors.get(i).first)) {
|
||||
filesData.add(editors.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1176,6 +1186,9 @@ public class Switcher extends AnAction implements DumbAware {
|
||||
@Nullable
|
||||
private static EditorWindow findAppropriateWindow(@NotNull FileInfo info) {
|
||||
if (info.second == null) return null;
|
||||
if (UISettings.getInstance().getEditorTabPlacement() == UISettings.TABS_NONE) {
|
||||
return info.second.getOwner().getCurrentWindow();
|
||||
}
|
||||
final EditorWindow[] windows = info.second.getOwner().getWindows();
|
||||
return ArrayUtil.contains(info.second, windows) ? info.second : windows.length > 0 ? windows[0] : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user