@@ -444,24 +444,26 @@ function! s:SlugToFileName(slug) abort
444444endfunction
445445
446446function ! s: ProblemSlugFromFileName () abort
447- let parts = split (expand (' %:t:r' ), ' \.' ) " Filename without the extension
447+ " 1-two_sum -> 1.two-sum
448+ let file_name = substitute (expand (' %:t:r' ), ' -' , ' \.' , ' g' )
449+ let parts = split (file_name, ' \.' ) " Filename without the extension
448450 if len (parts) == 1
449- " Old style, e.g. two-sum
451+ " Old style, e.g. two_sum
450452 return s: FileNameToSlug (parts[0 ])
451453 elseif len (parts) == 2 && parts[0 ] = ~ ' \v^[0-9]+$'
452- " New style, e.g. 1.two-sum
454+ " New style, e.g. 1.two_sum
453455 return s: FileNameToSlug (parts[1 ])
454456 elseif len (parts) == 2
455457 if parts[-1 ] = ~# ' ^\d\+$'
456- " Old style with submission id, e.g. two-sum .1234
458+ " Old style with submission id, e.g. two_sum .1234
457459 return s: FileNameToSlug (parts[0 ])
458460 else
459461 " There some problems like `面试题59 - II.dui_lie_de_zui_da_zhi_lcof.cpp` in leetcode-cn
460462 return s: FileNameToSlug (parts[-1 ])
461463 endif
462464 elseif len (parts) == 3
463465 if parts[-1 ] = ~# ' ^\d\+$'
464- " New style with submission id, e.g. 1.two-sum .1234
466+ " New style with submission id, e.g. 1.two_sum .1234
465467 return s: FileNameToSlug (parts[1 ])
466468 else
467469 " There some problems like `面试题 02.06.palindrome_linked_list_lcci.cpp` in leetcode-cn
@@ -527,7 +529,7 @@ function! s:HandleProblemListCR() abort
527529 let problem = s: GetProblem (problem_id)
528530 let problem_slug = problem[' slug' ]
529531 let problem_ext = s: SolutionFileExt (g: leetcode_solution_filetype )
530- let problem_file_name = printf (' %s. %s.%s' , problem_id,
532+ let problem_file_name = printf (' %s- %s.%s' , problem_id,
531533 \ s: SlugToFileName (problem_slug),
532534 \ problem_ext)
533535
@@ -1216,7 +1218,7 @@ function! s:HandleSubmissionsCR() abort
12161218 return
12171219 endif
12181220
1219- let file_name = printf (' %s. %s.%s.%s' ,
1221+ let file_name = printf (' %s- %s.%s.%s' ,
12201222 \ submission[' problem_id' ],
12211223 \ s: SlugToFileName (submission[' slug' ]),
12221224 \ submission_id, s: SolutionFileExt (submission[' filetype' ]))
0 commit comments