Skip to content

Commit

Permalink
[Inspector V2] Change selected node heuristic after navigation event …
Browse files Browse the repository at this point in the history
…triggering a tree refresh (#8645)
  • Loading branch information
elliette authored Dec 20, 2024
1 parent a6a8f23 commit ba8a14f
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ class InspectorController extends DisposableController
}
if ((_receivedFlutterNavigationEvent || _receivedIsolateReloadEvent) &&
extensionEventKind == 'Flutter.Frame') {
_refreshingAfterNavigationEvent = _receivedFlutterNavigationEvent;
_receivedFlutterNavigationEvent = false;
_receivedIsolateReloadEvent = false;
await refreshInspector();
Expand Down Expand Up @@ -519,6 +520,8 @@ class InspectorController extends DisposableController
}
}

var _refreshingAfterNavigationEvent = false;

RemoteDiagnosticsNode? _determineNewSelection(
RemoteDiagnosticsNode? previousSelection,
) {
Expand All @@ -536,6 +539,17 @@ class InspectorController extends DisposableController
) = _findClosestUnchangedAncestor(previousSelection);
if (closestUnchangedAncestor == null) return inspectorTree.root?.diagnostic;

// TODO(elliette): This might cause a race event that will set this to false
// for a subsequent navigate event. Consider passing the value of
// _refreshingAfterNavigationEvent through the method chain from where the
// navigation event is detected. This would require updating the interface
// of InspectorServiceClient.onForceRefresh, or refactoring to avoid doing
// so.
if (_refreshingAfterNavigationEvent) {
_refreshingAfterNavigationEvent = false;
return closestUnchangedAncestor;
}

const distanceOffset = 3;
final matchingDescendant = _findMatchingDescendant(
of: closestUnchangedAncestor,
Expand Down

0 comments on commit ba8a14f

Please sign in to comment.