Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion lib/src/model/analysis/analysis_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,16 @@ class AnalysisController extends AsyncNotifier<AnalysisState>
final pathChange = curState.currentPath != path;
final (currentNode, opening) = _nodeOpeningAt(_root, path);

bool pathWasExpanded = false;
if (pathChange) {
for (final child in currentNode.children) {
if (child.isCollapsed) {
child.isCollapsed = false;
pathWasExpanded = true;
}
}
}

// always show variation if the user plays a move
if (shouldForceShowVariation && currentNode is Branch && currentNode.isCollapsed) {
_root.updateAt(path, (node) {
Expand All @@ -697,7 +707,7 @@ class AnalysisController extends AsyncNotifier<AnalysisState>
// root view is only used to display move list, so we need to
// recompute the root view only when the nodelist length changes
// or a variation is hidden/shown
final rootView = shouldForceShowVariation || shouldRecomputeRootView
final rootView = shouldForceShowVariation || shouldRecomputeRootView || pathWasExpanded
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recomputing rootView is expensive. Are you sure about the performance implications? Seems like it would impact the fast forward/rewind feature.

IMO this should be disabled if fast forward/rewind and only apply to a single jump.

? _root.view
: curState.root;

Expand Down
14 changes: 13 additions & 1 deletion lib/src/model/study/study_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,16 @@ class StudyController extends AsyncNotifier<StudyState>
final pathChange = state.currentPath != path;
final currentNode = _root.nodeAt(path);

bool pathWasExpanded = false;
if (pathChange) {
for (final child in currentNode.children) {
if (child.isCollapsed) {
child.isCollapsed = false;
pathWasExpanded = true;
}
}
}

// always show variation if the user plays a move
if (shouldForceShowVariation && currentNode is Branch && currentNode.isCollapsed) {
_root.updateAt(path, (node) {
Expand All @@ -447,7 +457,9 @@ class StudyController extends AsyncNotifier<StudyState>
// root view is only used to display move list, so we need to
// recompute the root view only when the nodelist length changes
// or a variation is hidden/shown
final rootView = shouldForceShowVariation || shouldRecomputeRootView ? _root.view : state.root;
final rootView = shouldForceShowVariation || shouldRecomputeRootView || pathWasExpanded
? _root.view
: state.root;

final isForward = path.size > state.currentPath.size;
if (currentNode is Branch) {
Expand Down