IJPL-172840 Set a limit for tree expanded roots used for screen reader announcements

This fixes the crash caused by too many tree expanded notifications when nodes get expanded by searching in the tree, for example, in database schema selection tree (IDEA-359880)


(cherry picked from commit bac09fd9d689118ef9efc87a1ac0cebb09164329)

IJ-CR-151182

GitOrigin-RevId: 418181a5a8631c8719beb799ba88003a0ad78dcd
This commit is contained in:
Dmitry Drobotov
2024-12-09 13:38:34 +01:00
committed by intellij-monorepo-bot
parent 4748a2cbfc
commit 727fb4c760

View File

@@ -1506,7 +1506,8 @@ public class Tree extends JTree implements ComponentWithEmptyText, ComponentWith
markPathExpanded(path);
fireTreeExpanded(path);
var parent = path.getParentPath();
if (parent == null || !toExpand.contains(parent)) {
// Limit expanded roots to 10 to prevent too many announcements and performance issues caused by it.
if (expandRoots.size() <= 10 && (parent == null || !toExpand.contains(parent))) {
expandRoots.add(path);
}
}