File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33 "displayName" : " Save Commands" ,
44 "description" : " Simple VSCode Extension to save and execute terminal commands." ,
55 "icon" : " media/save-commands.png" ,
6- "version" : " 1.0.1 " ,
6+ "version" : " 1.0.2 " ,
77 "engines" : {
88 "vscode" : " ^1.74.0"
99 },
Original file line number Diff line number Diff line change @@ -98,12 +98,15 @@ export default class Command {
9898 }
9999
100100 const inputs : Record < string , string > = { } ;
101- for ( const placeholder of matches ) {
101+
102+ for ( const placeholder in matches ) {
102103 const input = await takeSingleInput ( {
103104 promptText : `${ resolveCommandType } | ${ this . name } | ${ placeholder } | ` ,
104105 placeholder : `Enter ${ placeholder } ` ,
105106 } ) ;
106- inputs [ placeholder ] = input ;
107+ matches [ placeholder ] . forEach ( ( match ) => {
108+ inputs [ match ] = input ;
109+ } ) ;
107110 }
108111 const resolvedCommand = this . command . replace ( regex , ( match ) => {
109112 if ( match in inputs ) {
Original file line number Diff line number Diff line change @@ -4,8 +4,19 @@ export abstract class PlaceholderType {
44
55 abstract wrapLabel ( label : string ) : string ;
66
7- extractPlaceholders = ( str : string ) : Array < string > | null => {
8- return str . match ( this . regex ) ;
7+ extractPlaceholders = ( str : string ) : Record < string , Set < string > > | null => {
8+ const matches = str . match ( this . regex ) ?? null ;
9+ if ( ! matches ) return null ;
10+ const placeholders : Record < string , Set < string > > = { }
11+ matches ?. map ( ( m ) => {
12+ const text = m . replace ( / ^ \W + | \W + $ / g, '' )
13+ if ( ! placeholders [ text ] ) {
14+ placeholders [ text ] = new Set ( [ m ] )
15+ } else {
16+ placeholders [ text ] . add ( m )
17+ }
18+ } ) ;
19+ return placeholders ;
920 } ;
1021
1122 static getPlaceholderTypeFromId ( id : string ) {
You can’t perform that action at this time.
0 commit comments