@@ -196,12 +196,13 @@ function FlagOperator({ mode, tw }) {
196196
197197// duplicate handler
198198function HandleDuplicateOperator ( arg ) {
199- const { action, template, link, position } = {
199+ const { action, template, link, position, field } = {
200200 ...{
201201 action : 'rename' ,
202202 template : '0 1 2 3 4 5 6 7 8 9' ,
203203 link : '-' ,
204204 position : 'back' ,
205+ field : [ 'name' ] ,
205206 } ,
206207 ...arg ,
207208 } ;
@@ -211,10 +212,13 @@ function HandleDuplicateOperator(arg) {
211212 if ( action === 'delete' ) {
212213 const chosen = { } ;
213214 return proxies . filter ( ( p ) => {
214- if ( chosen [ p . name ] ) {
215+ const key = field
216+ . map ( ( f ) => lodash . get ( p , f , '-' ) )
217+ . join ( '_' ) ;
218+ if ( chosen [ key ] ) {
215219 return false ;
216220 }
217- chosen [ p . name ] = true ;
221+ chosen [ key ] = true ;
218222 return true ;
219223 } ) ;
220224 } else if ( action === 'rename' ) {
@@ -223,21 +227,23 @@ function HandleDuplicateOperator(arg) {
223227 const counter = { } ;
224228 let maxLen = 0 ;
225229 proxies . forEach ( ( p ) => {
226- if ( typeof counter [ p . name ] === 'undefined' )
227- counter [ p . name ] = 1 ;
228- else counter [ p . name ] ++ ;
229- maxLen = Math . max (
230- counter [ p . name ] . toString ( ) . length ,
231- maxLen ,
232- ) ;
230+ const key = field
231+ . map ( ( f ) => lodash . get ( p , f , '-' ) )
232+ . join ( '_' ) ;
233+ if ( typeof counter [ key ] === 'undefined' ) counter [ key ] = 1 ;
234+ else counter [ key ] ++ ;
235+ maxLen = Math . max ( counter [ key ] . toString ( ) . length , maxLen ) ;
233236 } ) ;
234237 const increment = { } ;
235238 return proxies . map ( ( p ) => {
236- if ( counter [ p . name ] > 1 ) {
237- if ( typeof increment [ p . name ] == 'undefined' )
238- increment [ p . name ] = 1 ;
239+ const key = field
240+ . map ( ( f ) => lodash . get ( p , f , '-' ) )
241+ . join ( '_' ) ;
242+ if ( counter [ key ] > 1 ) {
243+ if ( typeof increment [ key ] == 'undefined' )
244+ increment [ key ] = 1 ;
239245 let num = '' ;
240- let cnt = increment [ p . name ] ++ ;
246+ let cnt = increment [ key ] ++ ;
241247 let numDigits = 0 ;
242248 while ( cnt > 0 ) {
243249 num = numbers [ cnt % 10 ] + num ;
0 commit comments