@@ -75,13 +75,37 @@ public static void initConsolePreferences() {
7575 @ NotNull final ConsoleView console ;
7676 @ NotNull final FlutterApp app ;
7777
78+ private int frameErrorCount = 0 ;
79+
7880 public FlutterConsoleLogManager (@ NotNull ConsoleView console , @ NotNull FlutterApp app ) {
7981 this .console = console ;
8082 this .app = app ;
8183
8284 assert (app .getVmService () != null );
8385 this .service = app .getVmService ();
8486
87+ app .addStateListener (new FlutterApp .FlutterAppListener () {
88+ @ Override
89+ public void notifyFrameRendered () {
90+ frameErrorCount = 0 ;
91+ }
92+
93+ @ Override
94+ public void stateChanged (FlutterApp .State newState ) {
95+ frameErrorCount = 0 ;
96+ }
97+
98+ @ Override
99+ public void notifyAppReloaded () {
100+ frameErrorCount = 0 ;
101+ }
102+
103+ @ Override
104+ public void notifyAppRestarted () {
105+ frameErrorCount = 0 ;
106+ }
107+ });
108+
85109 assert (app .getFlutterDebugProcess () != null );
86110 objectGroup = InspectorService .createGroup (app , app .getFlutterDebugProcess (), app .getVmService (), "console-group" );
87111 objectGroup .whenCompleteAsync ((group , error ) -> {
@@ -101,14 +125,6 @@ public void handleFlutterErrorEvent(@NotNull Event event) {
101125 final JsonObject jsonObject = extensionData .getJson ().getAsJsonObject ();
102126 final DiagnosticsNode diagnosticsNode = new DiagnosticsNode (jsonObject , objectGroup , app , false , null );
103127
104- final int errorsSinceReload ;
105- if (jsonObject .has ("errorsSinceReload" )) {
106- errorsSinceReload = jsonObject .get ("errorsSinceReload" ).getAsInt ();
107- }
108- else {
109- errorsSinceReload = 0 ;
110- }
111-
112128 // Send analytics for the diagnosticsNode.
113129 final String errorId = FlutterErrorHelper .getAnalyticsId (diagnosticsNode );
114130 if (errorId != null ) {
@@ -118,7 +134,7 @@ public void handleFlutterErrorEvent(@NotNull Event event) {
118134 if (FlutterSettings .getInstance ().isShowStructuredErrors ()) {
119135 queue .add (() -> {
120136 try {
121- processFlutterErrorEvent (diagnosticsNode , errorsSinceReload );
137+ processFlutterErrorEvent (diagnosticsNode );
122138 }
123139 catch (Throwable t ) {
124140 LOG .warn (t );
@@ -139,21 +155,21 @@ public void handleFlutterErrorEvent(@NotNull Event event) {
139155 /**
140156 * Pretty print the error using the available console syling attributes.
141157 */
142- private void processFlutterErrorEvent (@ NotNull DiagnosticsNode diagnosticsNode , int errorsSinceReload ) {
158+ private void processFlutterErrorEvent (@ NotNull DiagnosticsNode diagnosticsNode ) {
143159 final String description = " " + diagnosticsNode .toString () + " " ;
144160
145- final boolean terseError = errorsSinceReload != 0 ;
161+ frameErrorCount ++;
162+
163+ final boolean terseError = frameErrorCount > 1 ;
146164
147- // TODO(devoncarew): Potentially change the error separator chars based on the error type (overflow, ...).
148165 final String prefix = "════════" ;
149- final String multiplicity = errorsSinceReload == 0 ? "" : (" (" + (errorsSinceReload + 1 ) + ")" );
150166 final String suffix = "══" ;
151167
152168 console .print ("\n " + prefix , TITLE_CONTENT_TYPE );
153- console .print (multiplicity + description , NORMAL_CONTENT_TYPE );
169+ console .print (description , NORMAL_CONTENT_TYPE );
154170 console .print (
155171 StringUtil .repeat (errorSeparatorChar , Math .max (
156- errorSeparatorLength - prefix .length () - multiplicity . length () - description .length () - suffix .length (), 0 )),
172+ errorSeparatorLength - prefix .length () - description .length () - suffix .length (), 0 )),
157173 TITLE_CONTENT_TYPE );
158174 console .print (suffix + "\n " , TITLE_CONTENT_TYPE );
159175
0 commit comments