Skip to content

Fix issue where initial script was not always selected in File Explorer #3400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 27, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ class DebuggerController extends DisposableController
_showScriptLocation(ScriptLocation(scriptsHistory.current.value));
};
scriptsHistory.current.addListener(_scriptHistoryListener);
programExplorerController.initialize(currentScriptRef.value);
addAutoDisposeListener(currentScriptRef, () async {
if (!programExplorerController.initialized.value) {
await programExplorerController.initialize();
}
if (currentScriptRef.value != null) {
programExplorerController.selectScriptNode(currentScriptRef.value);
}
});

if (_service != null) {
initialize();
Expand Down Expand Up @@ -193,8 +200,6 @@ class DebuggerController extends DisposableController
// set to null to ensure that happens.
_scriptLocation.value = null;
_scriptLocation.value = scriptLocation;

programExplorerController.selectScriptNode(scriptLocation.scriptRef);
}

Future<Script> getScriptForRef(ScriptRef ref) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ProgramExplorerController extends DisposableController

/// Initializes the program structure.
// TODO(bkonyi): reinitialize after hot reload.
Future<void> initialize([ScriptRef initialScript]) async {
Future<void> initialize() async {
if (_initializing) {
return;
}
Expand Down Expand Up @@ -112,9 +112,6 @@ class ProgramExplorerController extends DisposableController
this,
_programStructure,
);
if (initialScript != null) {
_selectScriptNode(initialScript, nodes);
}
_rootObjectNodes.addAll(nodes);
_initialized.value = true;
}
Expand Down