mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
[flutter_tools] [DAP] Don't try to restart/reload if app hasn't started yet (#128267)
The editor is set to hot-reload-on-save by default so saving while the debug session is starting currently prints an error: Failed to Hot Reload: app 'null' not found  This change skips the call to `app.restart` if the app hasn't started yet to avoid printing an error.
This commit is contained in:
parent
6d4c4d75bf
commit
46007d61d2
@ -663,6 +663,12 @@ class FlutterDebugAdapter extends FlutterBaseDebugAdapter {
|
|||||||
bool fullRestart, [
|
bool fullRestart, [
|
||||||
String? reason,
|
String? reason,
|
||||||
]) async {
|
]) async {
|
||||||
|
// Don't do anything if the app hasn't started yet, as restarts and reloads
|
||||||
|
// can only operate on a running app.
|
||||||
|
if (_appId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final String progressId = fullRestart ? 'hotRestart' : 'hotReload';
|
final String progressId = fullRestart ? 'hotRestart' : 'hotReload';
|
||||||
final String progressMessage = fullRestart ? 'Hot restarting…' : 'Hot reloading…';
|
final String progressMessage = fullRestart ? 'Hot restarting…' : 'Hot reloading…';
|
||||||
final DapProgressReporter progress = startProgressNotification(
|
final DapProgressReporter progress = startProgressNotification(
|
||||||
|
@ -186,6 +186,30 @@ void main() {
|
|||||||
expect(adapter.dapToFlutterRequests, isNot(contains('app.stop')));
|
expect(adapter.dapToFlutterRequests, isNot(contains('app.stop')));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('does not call "app.restart" before app has been started', () async {
|
||||||
|
final MockFlutterDebugAdapter adapter = MockFlutterDebugAdapter(
|
||||||
|
fileSystem: MemoryFileSystem.test(style: fsStyle),
|
||||||
|
platform: platform,
|
||||||
|
simulateAppStarted: false,
|
||||||
|
);
|
||||||
|
|
||||||
|
final Completer<void> launchCompleter = Completer<void>();
|
||||||
|
final FlutterLaunchRequestArguments launchArgs = FlutterLaunchRequestArguments(
|
||||||
|
cwd: '/project',
|
||||||
|
program: 'foo.dart',
|
||||||
|
);
|
||||||
|
final Completer<void> restartCompleter = Completer<void>();
|
||||||
|
final RestartArguments restartArgs = RestartArguments();
|
||||||
|
|
||||||
|
await adapter.configurationDoneRequest(MockRequest(), null, () {});
|
||||||
|
await adapter.launchRequest(MockRequest(), launchArgs, launchCompleter.complete);
|
||||||
|
await launchCompleter.future;
|
||||||
|
await adapter.restartRequest(MockRequest(), restartArgs, restartCompleter.complete);
|
||||||
|
await restartCompleter.future;
|
||||||
|
|
||||||
|
expect(adapter.dapToFlutterRequests, isNot(contains('app.restart')));
|
||||||
|
});
|
||||||
|
|
||||||
test('includes Dart Debug extension progress update', () async {
|
test('includes Dart Debug extension progress update', () async {
|
||||||
final MockFlutterDebugAdapter adapter = MockFlutterDebugAdapter(
|
final MockFlutterDebugAdapter adapter = MockFlutterDebugAdapter(
|
||||||
fileSystem: MemoryFileSystem.test(style: fsStyle),
|
fileSystem: MemoryFileSystem.test(style: fsStyle),
|
||||||
|
Loading…
Reference in New Issue
Block a user