@@ -28,6 +28,32 @@ function renderStepButton(errorId: string, step: "previous" | "next", disabled:
2828 return `<button class="vc-step-btn vc-step-${ step } -btn" data-error-id="${ errorId } " data-vc-step="${ step } " title="${ label } " aria-label="${ label } " ${ disabled ? "disabled" : "" } type="button">${ renderCodicon ( icon ) } </button>` ;
2929}
3030
31+ function renderStepHeader (
32+ errorId : string ,
33+ current : VCSimplificationResult ,
34+ index : number ,
35+ stepCount : number ,
36+ ) : string {
37+ const chronologicalStep = stepCount - index ;
38+ const simplification = current . simplification ?. trim ( ) ;
39+ const label = simplification || "Original" ;
40+
41+ return /*html*/ `
42+ <div class="vc-step-header">
43+ <span class="vc-step-name" title="${ escapeHtml ( label ) } ">${ escapeHtml ( label ) } </span>
44+ <div class="vc-step-navigation">
45+ <span class="vc-step-position" aria-label="Simplification step ${ chronologicalStep } of ${ stepCount } ">
46+ ${ chronologicalStep } /${ stepCount }
47+ </span>
48+ <div class="vc-step-controls">
49+ ${ renderStepButton ( errorId , "previous" , index === stepCount - 1 ) }
50+ ${ renderStepButton ( errorId , "next" , index === 0 ) }
51+ </div>
52+ </div>
53+ </div>
54+ ` ;
55+ }
56+
3157export function handleVCImplicationStepClick ( target : Element ) : boolean {
3258 const errorId = target . getAttribute ( "data-error-id" ) ;
3359 const step = target . getAttribute ( "data-vc-step" ) ;
@@ -53,21 +79,19 @@ export function renderVCImplication(
5379 error . title ,
5480 error . message
5581 ] ) ) ;
56- const history : VCSimplificationResult [ ] = [ ] ;
82+ const steps : VCSimplificationResult [ ] = [ ] ;
5783 for ( let current : VCSimplificationResult | null = result ; current ; current = current . origin ) {
58- history . push ( current ) ;
84+ steps . push ( current ) ;
5985 }
6086
61- const index = Math . min ( stepIndexes . get ( errorId ) ?? 0 , history . length - 1 ) ;
87+ const index = Math . min ( stepIndexes . get ( errorId ) ?? 0 , steps . length - 1 ) ;
6288 stepIndexes . set ( errorId , index ) ;
89+ const current = steps [ index ] ;
6390
6491 return /*html*/ `
6592 <div class="container vc-container" data-error-id="${ errorId } ">
66- <div class="vc-chain">${ renderImplication ( history [ index ] . implication ) } </div>
67- <div class="vc-step-controls">
68- ${ renderStepButton ( errorId , "previous" , index === history . length - 1 ) }
69- ${ renderStepButton ( errorId , "next" , index === 0 ) }
70- </div>
93+ ${ steps . length > 1 ? renderStepHeader ( errorId , current , index , steps . length ) : "" }
94+ <div class="vc-chain">${ renderImplication ( current . implication ) } </div>
7195 </div>
7296 ` ;
7397}
0 commit comments