Skip to content

Commit 3a512e0

Browse files
committed
updated for version 7.4.642
Problem: When using "gf" escaped spaces are not handled. Solution: Recognize escaped spaces.
1 parent e5b9570 commit 3a512e0

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

src/misc2.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5474,6 +5474,7 @@ free_findfile()
54745474
*
54755475
* options:
54765476
* FNAME_MESS give error message when not found
5477+
* FNAME_UNESC unescape backslashes.
54775478
*
54785479
* Uses NameBuff[]!
54795480
*
@@ -5491,7 +5492,8 @@ find_directory_in_path(ptr, len, options, rel_fname)
54915492
}
54925493

54935494
char_u *
5494-
find_file_in_path_option(ptr, len, options, first, path_option, find_what, rel_fname, suffixes)
5495+
find_file_in_path_option(ptr, len, options, first, path_option,
5496+
find_what, rel_fname, suffixes)
54955497
char_u *ptr; /* file name */
54965498
int len; /* length of file name */
54975499
int options;
@@ -5530,6 +5532,13 @@ find_file_in_path_option(ptr, len, options, first, path_option, find_what, rel_f
55305532
file_name = NULL;
55315533
goto theend;
55325534
}
5535+
if (options & FNAME_UNESC)
5536+
{
5537+
/* Change all "\ " to " ". */
5538+
for (ptr = ff_file_to_find; *ptr != NUL; ++ptr)
5539+
if (ptr[0] == '\\' && ptr[1] == ' ')
5540+
mch_memmove(ptr, ptr + 1, STRLEN(ptr));
5541+
}
55335542
}
55345543

55355544
rel_to_curdir = (ff_file_to_find[0] == '.'

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ static char *(features[]) =
741741

742742
static int included_patches[] =
743743
{ /* Add new patch number below this line */
744+
/**/
745+
642,
744746
/**/
745747
641,
746748
/**/

src/vim.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,7 @@ extern char *(*dyn_libintl_textdomain)(const char *domainname);
939939
#define FNAME_INCL 8 /* apply 'includeexpr' */
940940
#define FNAME_REL 16 /* ".." and "./" are relative to the (current)
941941
file instead of the current directory */
942+
#define FNAME_UNESC 32 /* remove backslashes used for escaping */
942943

943944
/* Values for buflist_getfile() */
944945
#define GETF_SETMARK 0x01 /* set pcmark before jumping */

src/window.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6219,18 +6219,19 @@ grab_file_name(count, file_lnum)
62196219
long count;
62206220
linenr_T *file_lnum;
62216221
{
6222+
int options = FNAME_MESS|FNAME_EXP|FNAME_REL|FNAME_UNESC;
6223+
62226224
if (VIsual_active)
62236225
{
62246226
int len;
62256227
char_u *ptr;
62266228

62276229
if (get_visual_text(NULL, &ptr, &len) == FAIL)
62286230
return NULL;
6229-
return find_file_name_in_path(ptr, len,
6230-
FNAME_MESS|FNAME_EXP|FNAME_REL, count, curbuf->b_ffname);
6231+
return find_file_name_in_path(ptr, len, options,
6232+
count, curbuf->b_ffname);
62316233
}
6232-
return file_name_at_cursor(FNAME_MESS|FNAME_HYP|FNAME_EXP|FNAME_REL, count,
6233-
file_lnum);
6234+
return file_name_at_cursor(options | FNAME_HYP, count, file_lnum);
62346235

62356236
}
62366237

@@ -6310,14 +6311,19 @@ file_name_in_line(line, col, options, count, rel_fname, file_lnum)
63106311
* Also allow "://" when ':' is not in 'isfname'.
63116312
*/
63126313
len = 0;
6313-
while (vim_isfilec(ptr[len])
6314+
while (vim_isfilec(ptr[len]) || (ptr[len] == '\\' && ptr[len + 1] == ' ')
63146315
|| ((options & FNAME_HYP) && path_is_url(ptr + len)))
6316+
{
6317+
if (ptr[len] == '\\')
6318+
/* Skip over the "\" in "\ ". */
6319+
++len;
63156320
#ifdef FEAT_MBYTE
63166321
if (has_mbyte)
63176322
len += (*mb_ptr2len)(ptr + len);
63186323
else
63196324
#endif
63206325
++len;
6326+
}
63216327

63226328
/*
63236329
* If there is trailing punctuation, remove it.

0 commit comments

Comments
 (0)