File tree 1 file changed +10
-4
lines changed
1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -249,13 +249,19 @@ def load_svg_template(self):
249
249
if self .duplicate and self .edit_file_path :
250
250
# Re-use current name
251
251
name = os .path .basename (self .edit_file_path )
252
- # Splits the filename into "[base-part][optional space]([number]).svg
253
- match = re .match (r"^(.*?)(\s*)\(([0-9]*)\)\.svg$" , name )
252
+ # Splits the filename into:
253
+ # [base-part][optional space][([number])].svg
254
+ # Match groups are:
255
+ # 1: Base name ("title", "Title-2", "Title number 3000")
256
+ # 2: Space(s) preceding groups 3+4, IFF 3/4 are a match
257
+ # 3: The entire parenthesized number ("(1)", "(20)", "(1000)")
258
+ # 4: Just the number inside the parens ("1", "20", "1000")
259
+ match = re .match (r"^(.+?)(\s*)(\(([0-9]*)\))?\.svg$" , name )
254
260
# Make sure the new title has " (%d)" appended by default
255
261
name = match .group (1 ) + " (%d)"
256
- if match .group (3 ):
262
+ if match .group (4 ):
257
263
# Filename already contained a number -> start counting from there
258
- offset = int (match .group (3 ))
264
+ offset = int (match .group (4 ))
259
265
# -> only include space(s) if there before
260
266
name = match .group (1 ) + match .group (2 ) + "(%d)"
261
267
# Find an unused file name
You can’t perform that action at this time.
0 commit comments