Patch 8.1.1769
Problem: 'shellslash' is also used for completion.
Solution: Add the 'completeslash' option. (Yasuhiro Matsumoto, closes #3612)
Files: runtime/doc/options.txt, src/ex_getln.c, src/insexpand.c,
src/option.c, src/option.h, src/structs.h,
src/testdir/test_ins_complete.vim
*** ../vim-8.1.1768/runtime/doc/options.txt 2019-07-18 21:42:45.959840521
+0200
--- runtime/doc/options.txt 2019-07-28 16:31:21.047456307 +0200
***************
*** 1872,1877 ****
--- 1870,1890 ----
This option cannot be set from a |modeline| or in the |sandbox|, for
security reasons.
+ *'completeslash'* *'csl'*
+ 'completeslash' 'csl' string (default: "")
+ local to buffer
+ {not in Vi} {only for MS-Windows}
+ When this option is set it overrules 'shellslash' for completion:
+ - When this option is set to "slash", a forward slash is used for path
+ completion in insert mode. This is useful when editing HTML tag, or
+ Makefile with 'noshellslash' on Windows.
+ - When this option is set to "backslash", backslash is used. This is
+ useful when editing a batch file with 'shellslash' set on Windows.
+ - When this option is empty, same character is used as for
+ 'shellslash'.
+ For Insert mode completion the buffer-local value is used. For
+ command line completion the global value is used.
+
*'completeopt'* *'cot'*
'completeopt' 'cot' string (default: "menu,preview")
global
***************
*** 6519,6525 ****
'shellslash' only works when a backslash can be used as a path
separator. To test if this is so use: >
if exists('+shellslash')
! <
*'shelltemp'* *'stmp'* *'noshelltemp'* *'nostmp'*
'shelltemp' 'stmp' boolean (Vi default off, Vim default on)
global
--- 6530,6537 ----
'shellslash' only works when a backslash can be used as a path
separator. To test if this is so use: >
if exists('+shellslash')
! < Also see 'completeslash'.
!
*'shelltemp'* *'stmp'* *'noshelltemp'* *'nostmp'*
'shelltemp' 'stmp' boolean (Vi default off, Vim default on)
global
*** ../vim-8.1.1768/src/ex_getln.c 2019-07-21 21:51:56.023609378 +0200
--- src/ex_getln.c 2019-07-28 16:35:38.366208776 +0200
***************
*** 5095,5100 ****
--- 5095,5120 ----
ret = expand_wildcards_eval(&pat, num_file, file, flags);
if (free_pat)
vim_free(pat);
+ #ifdef BACKSLASH_IN_FILENAME
+ if (p_csl[0] != NUL)
+ {
+ int i;
+
+ for (i = 0; i < *num_file; ++i)
+ {
+ char_u *ptr = (*file)[i];
+
+ while (*ptr != NUL)
+ {
+ if (p_csl[0] == 's' && *ptr == '\\')
+ *ptr = '/';
+ else if (p_csl[0] == 'b' && *ptr == '/')
+ *ptr = '\\';
+ ptr += (*mb_ptr2len)(ptr);
+ }
+ }
+ }
+ #endif
return ret;
}
*** ../vim-8.1.1768/src/insexpand.c 2019-05-28 23:08:12.068648696 +0200
--- src/insexpand.c 2019-07-28 16:32:06.879234660 +0200
***************
*** 2669,2674 ****
--- 2669,2694 ----
// May change home directory back to "~".
tilde_replace(compl_pattern, num_matches, matches);
+ #ifdef BACKSLASH_IN_FILENAME
+ if (curbuf->b_p_csl[0] != NUL)
+ {
+ int i;
+
+ for (i = 0; i < num_matches; ++i)
+ {
+ char_u *ptr = matches[i];
+
+ while (*ptr != NUL)
+ {
+ if (curbuf->b_p_csl[0] == 's' && *ptr == '\\')
+ *ptr = '/';
+ else if (curbuf->b_p_csl[0] == 'b' && *ptr == '/')
+ *ptr = '\\';
+ ptr += (*mb_ptr2len)(ptr);
+ }
+ }
+ }
+ #endif
ins_compl_add_matches(num_matches, matches, p_fic || p_wic);
}
break;
*** ../vim-8.1.1768/src/option.c 2019-07-23 22:15:21.307518880 +0200
--- src/option.c 2019-07-28 16:22:45.053924308 +0200
***************
*** 88,93 ****
--- 88,94 ----
# define PV_DICT OPT_BOTH(OPT_BUF(BV_DICT))
# define PV_TSR OPT_BOTH(OPT_BUF(BV_TSR))
#endif
+ #define PV_CSL OPT_BUF(BV_CSL)
#ifdef FEAT_COMPL_FUNC
# define PV_CFU OPT_BUF(BV_CFU)
#endif
***************
*** 892,897 ****
--- 893,907 ----
{(char_u *)0L, (char_u *)0L}
#endif
SCTX_INIT},
+ {"completeslash", "csl", P_STRING|P_VI_DEF|P_VIM,
+ #if defined(FEAT_INS_EXPAND) && defined(BACKSLASH_IN_FILENAME)
+ (char_u *)&p_csl, PV_CSL,
+ {(char_u *)"", (char_u *)0L}
+ #else
+ (char_u *)NULL, PV_NONE,
+ {(char_u *)0L, (char_u *)0L}
+ #endif
+ SCTX_INIT},
{"confirm", "cf", P_BOOL|P_VI_DEF,
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
(char_u *)&p_confirm, PV_NONE,
***************
*** 3238,3243 ****
--- 3248,3256 ----
#endif
#ifdef FEAT_INS_EXPAND
static char *(p_cot_values[]) = {"menu", "menuone", "longest", "preview",
"noinsert", "noselect", NULL};
+ # ifdef BACKSLASH_IN_FILENAME
+ static char *(p_csl_values[]) = {"slash", "backslash", NULL};
+ # endif
#endif
#ifdef FEAT_SIGNS
static char *(p_scl_values[]) = {"yes", "no", "auto", "number", NULL};
***************
*** 7409,7415 ****
}
}
! /* 'completeopt' */
else if (varp == &p_cot)
{
if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
--- 7422,7428 ----
}
}
! // 'completeopt'
else if (varp == &p_cot)
{
if (check_opt_strings(p_cot, p_cot_values, TRUE) != OK)
***************
*** 7417,7423 ****
else
completeopt_was_set();
}
! #endif /* FEAT_INS_EXPAND */
#ifdef FEAT_SIGNS
// 'signcolumn'
--- 7430,7445 ----
else
completeopt_was_set();
}
!
! # ifdef BACKSLASH_IN_FILENAME
! // 'completeslash'
! else if (varp == &curbuf->b_p_csl)
! {
! if (check_opt_strings(p_csl, p_csl_values, FALSE) != OK)
! errmsg = e_invarg;
! }
! # endif
! #endif // FEAT_INS_EXPAND
#ifdef FEAT_SIGNS
// 'signcolumn'
***************
*** 11110,11116 ****
#endif
case PV_MENC: return *curbuf->b_p_menc != NUL
? (char_u *)&(curbuf->b_p_menc) : p->var;
-
#ifdef FEAT_ARABIC
case PV_ARAB: return (char_u *)&(curwin->w_p_arab);
#endif
--- 11132,11137 ----
***************
*** 11197,11202 ****
--- 11218,11226 ----
#endif
#ifdef FEAT_INS_EXPAND
case PV_CPT: return (char_u *)&(curbuf->b_p_cpt);
+ # ifdef BACKSLASH_IN_FILENAME
+ case PV_CSL: return (char_u *)&(curbuf->b_p_csl);
+ # endif
#endif
#ifdef FEAT_COMPL_FUNC
case PV_CFU: return (char_u *)&(curbuf->b_p_cfu);
***************
*** 11591,11596 ****
--- 11615,11623 ----
buf->b_p_swf = cmdmod.noswapfile ? FALSE : p_swf;
#ifdef FEAT_INS_EXPAND
buf->b_p_cpt = vim_strsave(p_cpt);
+ # ifdef BACKSLASH_IN_FILENAME
+ buf->b_p_csl = vim_strsave(p_csl);
+ # endif
#endif
#ifdef FEAT_COMPL_FUNC
buf->b_p_cfu = vim_strsave(p_cfu);
*** ../vim-8.1.1768/src/option.h 2019-07-19 23:15:09.817150088 +0200
--- src/option.h 2019-07-28 16:13:15.024520454 +0200
***************
*** 412,417 ****
--- 412,420 ----
EXTERN int p_cp; // 'compatible'
#ifdef FEAT_INS_EXPAND
EXTERN char_u *p_cot; // 'completeopt'
+ # ifdef BACKSLASH_IN_FILENAME
+ EXTERN char_u *p_csl; // 'completeslash'
+ # endif
EXTERN long p_ph; // 'pumheight'
EXTERN long p_pw; // 'pumwidth'
#endif
***************
*** 997,1002 ****
--- 1000,1008 ----
, BV_DICT
, BV_TSR
#endif
+ #ifdef BACKSLASH_IN_FILENAME
+ , BV_CSL
+ #endif
#ifdef FEAT_COMPL_FUNC
, BV_CFU
#endif
*** ../vim-8.1.1768/src/structs.h 2019-07-26 22:19:56.217463206 +0200
--- src/structs.h 2019-07-28 16:15:27.839937027 +0200
***************
*** 1198,1203 ****
--- 1198,1204 ----
// Initial size for a hashtable. Our items are relatively small and growing
// is expensive, thus use 16 as a start. Must be a power of 2.
+ // This allows for storing 10 items (2/3 of 16) before a resize is needed.
#define HT_INIT_SIZE 16
typedef struct hashtable_S
***************
*** 2395,2400 ****
--- 2396,2404 ----
#ifdef FEAT_INS_EXPAND
char_u *b_p_cpt; // 'complete'
#endif
+ #ifdef BACKSLASH_IN_FILENAME
+ char_u *b_p_csl; // 'completeslash'
+ #endif
#ifdef FEAT_COMPL_FUNC
char_u *b_p_cfu; // 'completefunc'
char_u *b_p_ofu; // 'omnifunc'
*** ../vim-8.1.1768/src/testdir/test_ins_complete.vim 2019-07-22
21:55:13.891251828 +0200
--- src/testdir/test_ins_complete.vim 2019-07-28 16:11:37.456936593 +0200
***************
*** 331,333 ****
--- 331,380 ----
delcom GetInput
set wildmenu& wildchar&
endfunc
+
+ " Test for insert path completion with completeslash option
+ func Test_ins_completeslash()
+ if !has('win32')
+ return
+ endif
+
+ call mkdir('Xdir')
+
+ let orig_shellslash = &shellslash
+ set cpt&
+
+ new
+
+ set noshellslash
+
+ set completeslash=
+ exe "normal oXd\<C-X>\<C-F>"
+ call assert_equal('Xdir\', getline('.'))
+
+ set completeslash=backslash
+ exe "normal oXd\<C-X>\<C-F>"
+ call assert_equal('Xdir\', getline('.'))
+
+ set completeslash=slash
+ exe "normal oXd\<C-X>\<C-F>"
+ call assert_equal('Xdir/', getline('.'))
+
+ set shellslash
+
+ set completeslash=
+ exe "normal oXd\<C-X>\<C-F>"
+ call assert_equal('Xdir/', getline('.'))
+
+ set completeslash=backslash
+ exe "normal oXd\<C-X>\<C-F>"
+ call assert_equal('Xdir\', getline('.'))
+
+ set completeslash=slash
+ exe "normal oXd\<C-X>\<C-F>"
+ call assert_equal('Xdir/', getline('.'))
+ %bw!
+ call delete('Xdir', 'rf')
+
+ let &shellslash = orig_shellslash
+ endfunc
+
*** ../vim-8.1.1768/src/version.c 2019-07-28 15:28:42.083404751 +0200
--- src/version.c 2019-07-28 16:33:52.106724789 +0200
***************
*** 779,780 ****
--- 779,782 ----
{ /* Add new patch number below this line */
+ /**/
+ 1769,
/**/
--
Are leaders born or made? And if they're made, can we return them under
warranty?
(Scott Adams - The Dilbert principle)
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/201907281437.x6SEb9Vn004320%40masaka.moolenaar.net.