@@ -4679,8 +4679,58 @@ vim_findfile_init(path, filename, stopdirs, level, free_visited, find_what,
46794679 }
46804680 STRCPY (ff_expand_buffer , search_ctx -> ffsc_start_dir );
46814681 add_pathsep (ff_expand_buffer );
4682- STRCAT (ff_expand_buffer , search_ctx -> ffsc_fix_path );
4683- add_pathsep (ff_expand_buffer );
4682+ {
4683+ char_u * buf = alloc (STRLEN (ff_expand_buffer )
4684+ + STRLEN (search_ctx -> ffsc_fix_path ));
4685+
4686+ STRCPY (buf , ff_expand_buffer );
4687+ STRCAT (buf , search_ctx -> ffsc_fix_path );
4688+ if (mch_isdir (buf ))
4689+ {
4690+ STRCAT (ff_expand_buffer , search_ctx -> ffsc_fix_path );
4691+ add_pathsep (ff_expand_buffer );
4692+ }
4693+ #ifdef FEAT_PATH_EXTRA
4694+ else
4695+ {
4696+ char_u * p = vim_strrchr (search_ctx -> ffsc_fix_path , PATHSEP );
4697+ char_u * wc_path = NUL ;
4698+ char_u * temp = NUL ;
4699+ int len = 0 ;
4700+
4701+ if (p != NULL )
4702+ {
4703+ len = p - search_ctx -> ffsc_fix_path ;
4704+ STRNCAT (ff_expand_buffer , search_ctx -> ffsc_fix_path , len );
4705+ add_pathsep (ff_expand_buffer );
4706+ }
4707+ else
4708+ len = STRLEN (search_ctx -> ffsc_fix_path );
4709+
4710+ if (search_ctx -> ffsc_wc_path != NULL )
4711+ {
4712+ wc_path = vim_strsave (search_ctx -> ffsc_wc_path );
4713+ temp = alloc (STRLEN (search_ctx -> ffsc_wc_path )
4714+ + (STRLEN (search_ctx -> ffsc_fix_path ) - len ));
4715+ }
4716+
4717+ if (temp == NULL || wc_path == NULL )
4718+ {
4719+ vim_free (buf );
4720+ vim_free (temp );
4721+ vim_free (wc_path );
4722+ goto error_return ;
4723+ }
4724+
4725+ STRCPY (temp , search_ctx -> ffsc_fix_path + len );
4726+ STRCAT (temp , search_ctx -> ffsc_wc_path );
4727+ vim_free (search_ctx -> ffsc_wc_path );
4728+ vim_free (wc_path );
4729+ search_ctx -> ffsc_wc_path = temp ;
4730+ }
4731+ #endif
4732+ vim_free (buf );
4733+ }
46844734
46854735 sptr = ff_create_stack_element (ff_expand_buffer ,
46864736#ifdef FEAT_PATH_EXTRA
0 commit comments