mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Generate Test: do not reset position when navigating to a just-closed file
This commit is contained in:
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
import com.intellij.openapi.fileEditor.impl.EditorHistoryManager;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.PopupChooserBuilder;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
@@ -100,8 +101,13 @@ public final class NavigationUtil {
|
||||
VirtualFile vFile = file.getVirtualFile();
|
||||
if (vFile == null) return false;
|
||||
|
||||
if (!EditorHistoryManager.getInstance(elt.getProject()).hasBeenOpen(vFile)) return false;
|
||||
|
||||
final FileEditorManager fem = FileEditorManager.getInstance(elt.getProject());
|
||||
if (!fem.isFileOpen(vFile)) return false;
|
||||
if (!fem.isFileOpen(vFile)) {
|
||||
fem.openFile(vFile, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
final TextRange range = elt.getTextRange();
|
||||
if (range == null) return false;
|
||||
|
||||
+7
@@ -229,6 +229,13 @@ public final class EditorHistoryManager extends AbstractProjectComponent impleme
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean hasBeenOpen(@NotNull VirtualFile f) {
|
||||
for (HistoryEntry each : myEntriesList) {
|
||||
if (each.myFile == f) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes specified <code>file</code> from history. The method does
|
||||
* nothing if <code>file</code> is not in the history.
|
||||
|
||||
Reference in New Issue
Block a user