mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 15:52:01 +07:00
IJPL-160019 Fix restoring tree paths on workspace switch
This regression is caused by the fact that CachedTreePresentation doesn't work well yet with trees that are already loaded. In this particular case, though, it's not desirable to use presentation caching because the cached presentation may not match the actual tree at all. So let's introduce an internal method to skip presentation caching and use it there. GitOrigin-RevId: 1d756971f87b4a2803d3e05b9ec41de7b7a76bb6
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4111cfc875
commit
06fa278008
@@ -96,6 +96,7 @@ public abstract class AbstractProjectViewPane implements UiCompatibleDataProvide
|
||||
private final Map<String,TreeState> myReadTreeState = new HashMap<>();
|
||||
private final AtomicBoolean myTreeStateRestored = new AtomicBoolean();
|
||||
boolean myNonEmptyTreeStateRestored = false;
|
||||
boolean myPersistingPresentationEnabled = true;
|
||||
private String mySubId;
|
||||
private static final @NonNls String ELEMENT_SUB_PANE = "subPane";
|
||||
private static final @NonNls String ATTRIBUTE_SUB_ID = "subId";
|
||||
@@ -576,6 +577,17 @@ public abstract class AbstractProjectViewPane implements UiCompatibleDataProvide
|
||||
}
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public void writeExternalWithoutPresentations(Element element) {
|
||||
myPersistingPresentationEnabled = false;
|
||||
try {
|
||||
writeExternal(element);
|
||||
}
|
||||
finally {
|
||||
myPersistingPresentationEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void writeExternal(Element element) {
|
||||
saveExpandedPaths();
|
||||
for (Map.Entry<String, TreeState> entry : myReadTreeState.entrySet()) {
|
||||
@@ -591,7 +603,8 @@ public abstract class AbstractProjectViewPane implements UiCompatibleDataProvide
|
||||
}
|
||||
|
||||
protected @NotNull TreeState createTreeState(@NotNull JTree tree) {
|
||||
return TreeState.createOn(tree, true, false, Registry.is("ide.project.view.persist.cached.presentation", true));
|
||||
var persistPresentation = myPersistingPresentationEnabled && Registry.is("ide.project.view.persist.cached.presentation", true);
|
||||
return TreeState.createOn(tree, true, false, persistPresentation);
|
||||
}
|
||||
|
||||
protected void saveExpandedPaths() {
|
||||
|
||||
@@ -33,7 +33,11 @@ final class ProjectViewContextProvider extends WorkingContextProvider {
|
||||
public void saveContext(@NotNull Project project, @NotNull Element toElement) throws WriteExternalException {
|
||||
for (AbstractProjectViewPane pane : AbstractProjectViewPane.EP.getExtensions(project)) {
|
||||
Element paneElement = new Element(pane.getId());
|
||||
pane.writeExternal(paneElement);
|
||||
// When switching between branches, we don't want to persist presentations,
|
||||
// as they likely won't be applicable to another branch.
|
||||
// Besides, it causes glitches, as the tree is already loaded,
|
||||
// and the persist/restore presentation mechanism assumes an initially empty tree.
|
||||
pane.writeExternalWithoutPresentations(paneElement);
|
||||
toElement.addContent(paneElement);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user