@@ -34,6 +34,23 @@ function extractVersionFromContent(content: string): string {
3434 return "16.0.0" ;
3535}
3636
37+ function getSelectionSummary ( generator : ReturnType < typeof useOverrideGenerator > ) : string {
38+ const activeSection = generator . activeSection . value ;
39+ const definition = generator . activeSectionDefinition . value ;
40+
41+ if ( ! activeSection || ! definition ) {
42+ return "" ;
43+ }
44+
45+ if ( definition . mode === "range" && activeSection . range ) {
46+ return `${ definition . label } : lines ${ activeSection . range . start } -${ activeSection . range . end } ` ;
47+ } else if ( definition . mode === "lines" && activeSection . lines . length > 0 ) {
48+ return `${ definition . label } : ${ activeSection . lines . length } line(s)` ;
49+ }
50+
51+ return `${ definition . label } : not set` ;
52+ }
53+
3754export function useGenerateOverrideCommand ( ) {
3855 const activeEditor = useActiveTextEditor ( ) ;
3956 const generator = useOverrideGenerator ( ) ;
@@ -47,21 +64,44 @@ export function useGenerateOverrideCommand() {
4764 }
4865
4966 if ( generator . mode . value === "selecting" ) {
50- const action = await window . showQuickPick (
51- [
52- {
53- label : `$(check) Confirm (lines ${ generator . selectionStart . value } -${ generator . selectionEnd . value } )` ,
54- action : "confirm" ,
55- } ,
56- { label : "$(close) Cancel Selection" , action : "cancel" } ,
57- ] ,
67+ const doneCount = generator . doneSections . value . length ;
68+ const totalCount = generator . sections . value . length ;
69+ const summary = getSelectionSummary ( generator ) ;
70+
71+ const items = [
5872 {
59- placeHolder : "Override selection is active. Click lines in editor to adjust." ,
73+ label : generator . activeSection . value
74+ ? `$(check) Confirm ${ generator . activeSectionDefinition . value ?. label ?? "Section" } `
75+ : `$(check) Finish (${ doneCount } /${ totalCount } sections)` ,
76+ action : "confirm" as const ,
77+ description : summary ,
6078 } ,
61- ) ;
79+ { label : "$(close) Cancel Selection" , action : "cancel" as const } ,
80+ ] ;
81+
82+ const action = await window . showQuickPick ( items , {
83+ placeHolder : generator . activeSection . value
84+ ? `Editing ${ generator . activeSectionDefinition . value ?. label } . Click lines in editor to adjust.`
85+ : "All sections complete. Confirm to generate override." ,
86+ } ) ;
6287
6388 if ( action ?. action === "confirm" ) {
64- const override = generator . confirm ( ) ;
89+ if ( generator . activeSection . value ) {
90+ const confirmed = generator . confirmActiveSection ( ) ;
91+ if ( ! confirmed ) {
92+ window . showWarningMessage ( "Selection is not valid. Please adjust the selection." ) ;
93+ return ;
94+ }
95+
96+ if ( generator . activeSection . value ) {
97+ window . showInformationMessage (
98+ `Section confirmed. Now editing: ${ generator . activeSectionDefinition . value ?. label } ` ,
99+ ) ;
100+ return ;
101+ }
102+ }
103+
104+ const override = generator . confirmAll ( ) ;
65105 if ( override ) {
66106 const json = JSON . stringify ( override , null , 2 ) ;
67107 await env . clipboard . writeText ( json ) ;
@@ -86,7 +126,7 @@ export function useGenerateOverrideCommand() {
86126 await vscodeCommands . executeCommand ( "ucd:selection.focus" ) ;
87127
88128 window . showInformationMessage (
89- `Selection mode active (lines ${ detected . start } -${ detected . end } ). Click to set start, click again to set end . Run command again to confirm.` ,
129+ `Selection mode active. Editing: Heading (lines ${ detected . start } -${ detected . end } ). Click to adjust . Run command again to confirm.` ,
90130 ) ;
91131 } ) ;
92132}
0 commit comments