@@ -2,7 +2,7 @@ import * as vscode from "vscode";
22import * as v from "valibot" ;
33import * as crypto from "crypto" ;
44
5- import { StatusSchema , type Status } from "../../shared/enums" ;
5+ import type { Status } from "../../shared/enums" ;
66import BaseViewProvider from "./BaseViewProvider" ;
77import {
88 compile ,
@@ -29,21 +29,11 @@ import {
2929 OpenMessageSchema ,
3030 ProviderMessageSchema ,
3131 SaveMessageSchema ,
32- StateIdValue ,
3332 ToggleVisibilityMessageSchema ,
3433 ViewMessageSchema ,
35- type StateId ,
3634 type WebviewMessage ,
3735} from "../../shared/stress-messages" ;
38-
39- const StressDataSchema = v . object ( {
40- stdin : v . fallback ( v . string ( ) , "" ) ,
41- stdout : v . fallback ( v . string ( ) , "" ) ,
42- stderr : v . fallback ( v . string ( ) , "" ) ,
43- status : v . fallback ( StatusSchema , "NA" ) ,
44- state : v . picklist ( StateIdValue ) ,
45- shown : v . fallback ( v . boolean ( ) , true ) ,
46- } ) ;
36+ import { StressDataSchema , type StateId } from "../../shared/schemas" ;
4737
4838const FileDataSchema = v . object ( {
4939 interactiveMode : v . fallback ( v . boolean ( ) , false ) ,
@@ -277,7 +267,6 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
277267 if ( ! ctx ) return ;
278268
279269 super . _postMessage ( { type : "INIT" , interactiveMode : ctx . interactiveMode } ) ;
280- super . _postMessage ( { type : "CLEAR" } ) ;
281270
282271 const resendTruncatedData = ( handler : TextHandler ) => {
283272 const data = handler . data ;
@@ -286,6 +275,7 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
286275 } ;
287276
288277 for ( const state of ctx . state ) {
278+ super . _postMessage ( { type : "CLEAR" , id : state . state } ) ;
289279 super . _postMessage ( {
290280 type : "STATUS" ,
291281 id : state . state ,
@@ -414,12 +404,13 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
414404 } ,
415405 file
416406 ) ;
417- state . stdout . reset ( ) ;
418- state . stderr . reset ( ) ;
419407 return compilePromise
420408 . then ( ( res ) => {
421409 if ( res . code !== 0 ) {
422410 state . status = "CE" ;
411+ super . _postMessage ( { type : "CLEAR" , id : state . state } , file ) ;
412+ state . stdout . reset ( ) ;
413+ state . stderr . reset ( ) ;
423414 state . stdout . write ( res . stdout , "final" ) ;
424415 state . stderr . write ( res . stderr , "final" ) ;
425416 super . _postMessage ( { type : "STATUS" , id : state . state , status : "CE" } , file ) ;
@@ -435,12 +426,6 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
435426 } ) ;
436427 } ;
437428
438- super . _postMessage (
439- {
440- type : "CLEAR" ,
441- } ,
442- file
443- ) ;
444429 const results = await Promise . all ( [
445430 addCompileTask ( generatorState , solutionSettings . generatorFile ! ) ,
446431 addCompileTask ( solutionState , file ) ,
@@ -491,8 +476,8 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
491476
492477 const start = Date . now ( ) ;
493478 while ( ! ctx . stopFlag && ( timeLimit === 0 || Date . now ( ) - start <= timeLimit ) ) {
494- super . _postMessage ( { type : "CLEAR" } , file ) ;
495479 for ( const state of ctx . state ) {
480+ super . _postMessage ( { type : "CLEAR" , id : state . state } , file ) ;
496481 state . stdin . reset ( ) ;
497482 state . stdout . reset ( ) ;
498483 state . stderr . reset ( ) ;
@@ -585,13 +570,12 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
585570
586571 if ( ctx . clearFlag ) {
587572 for ( const state of ctx . state ) {
573+ super . _postMessage ( { type : "CLEAR" , id : state . state } , file ) ;
588574 state . stdin . reset ( ) ;
589575 state . stdout . reset ( ) ;
590576 state . stderr . reset ( ) ;
591577 state . status = "NA" ;
592578 }
593-
594- super . _postMessage ( { type : "CLEAR" } , file ) ;
595579 }
596580 ctx . clearFlag = false ;
597581
@@ -750,6 +734,7 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
750734 this . stop ( ) ;
751735 } else {
752736 for ( const state of ctx . state ) {
737+ super . _postMessage ( { type : "CLEAR" , id : state . state } ) ;
753738 state . stdin . reset ( ) ;
754739 state . stdout . reset ( ) ;
755740 state . stderr . reset ( ) ;
@@ -761,7 +746,6 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
761746 status : "NA" ,
762747 } ) ;
763748 }
764- super . _postMessage ( { type : "CLEAR" } ) ;
765749
766750 if ( this . _currentFile ) {
767751 void this . _saveState ( this . _currentFile ) ;
0 commit comments