Skip to content

Commit b7c84b6

Browse files
authored
Show paused at breakpoint overlay (#1476)
1 parent a23b3a5 commit b7c84b6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

dwds/lib/src/debugging/debugger.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class Debugger extends Domain {
6767

6868
PauseState _pauseState = PauseState.none;
6969

70+
bool _pausedOverlayVisible = false;
71+
7072
String get pauseState => _pauseModePauseStates.entries
7173
.firstWhere((entry) => entry.value == _pauseState)
7274
.key;
@@ -392,6 +394,25 @@ class Debugger extends Domain {
392394
return await inspector.jsCallFunctionOn(receiver, expression, args);
393395
}
394396

397+
// Renders the paused at breakpoint overlay over the application.
398+
void _showPausedOverlay() async {
399+
if (_pausedOverlayVisible) return;
400+
handleErrorIfPresent(await _remoteDebugger?.sendCommand('DOM.enable'));
401+
handleErrorIfPresent(await _remoteDebugger?.sendCommand('Overlay.enable'));
402+
handleErrorIfPresent(await _remoteDebugger
403+
?.sendCommand('Overlay.setPausedInDebuggerMessage', params: {
404+
'message': 'Paused in Dart DevTools',
405+
}));
406+
_pausedOverlayVisible = true;
407+
}
408+
409+
// Removes the paused at breakpoint overlay from the application.
410+
void _hidePausedOverlay() async {
411+
if (!_pausedOverlayVisible) return;
412+
handleErrorIfPresent(await _remoteDebugger?.sendCommand('Overlay.disable'));
413+
_pausedOverlayVisible = false;
414+
}
415+
395416
/// Calls the Chrome Runtime.getProperties API for the object with [objectId].
396417
///
397418
/// Note that the property names are JS names, e.g.
@@ -563,6 +584,7 @@ class Debugger extends Domain {
563584
logger.warning('Error calculating Dart frames', e, s);
564585
}
565586

587+
_showPausedOverlay();
566588
isolate.pauseEvent = event;
567589
_streamNotify('Debug', event);
568590
}
@@ -579,6 +601,8 @@ class Debugger extends Domain {
579601
kind: EventKind.kResume,
580602
timestamp: DateTime.now().millisecondsSinceEpoch,
581603
isolate: inspector.isolateRef);
604+
605+
_hidePausedOverlay();
582606
isolate.pauseEvent = event;
583607
_streamNotify('Debug', event);
584608
}

0 commit comments

Comments
 (0)