mirror of
https://github.com/vim/vim.git
synced 2025-10-04 05:25:06 -04:00
patch 7.4.2236
Problem: The 'langnoremap' option leads to double negatives. And it does not work for the last character of a mapping. Solution: Add 'langremap' with the opposite value. Keep 'langnoremap' for backwards compatibility. Make it work for the last character of a mapping. Make the test work.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
" The default vimrc file.
|
" The default vimrc file.
|
||||||
"
|
"
|
||||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
" Last change: 2016 Aug 20
|
" Last change: 2016 Aug 21
|
||||||
"
|
"
|
||||||
" This is loaded if no vimrc file was found.
|
" This is loaded if no vimrc file was found.
|
||||||
" Except when Vim is run with "-u NONE" or "-C".
|
" Except when Vim is run with "-u NONE" or "-C".
|
||||||
@@ -107,9 +107,9 @@ if !exists(":DiffOrig")
|
|||||||
\ | wincmd p | diffthis
|
\ | wincmd p | diffthis
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has('langmap') && exists('+langnoremap')
|
if has('langmap') && exists('+langremap')
|
||||||
" Prevent that the langmap option applies to characters that result from a
|
" Prevent that the langmap option applies to characters that result from a
|
||||||
" mapping. If unset (default), this may break plugins (but it's backward
|
" mapping. If set (default), this may break plugins (but it's backward
|
||||||
" compatible).
|
" compatible).
|
||||||
set langnoremap
|
set nolangremap
|
||||||
endif
|
endif
|
||||||
|
@@ -135,7 +135,7 @@
|
|||||||
do { \
|
do { \
|
||||||
if (*p_langmap \
|
if (*p_langmap \
|
||||||
&& (condition) \
|
&& (condition) \
|
||||||
&& (!p_lnr || (p_lnr && typebuf_maplen() == 0)) \
|
&& (p_lrm || (!p_lrm && KeyTyped)) \
|
||||||
&& !KeyStuffed \
|
&& !KeyStuffed \
|
||||||
&& (c) >= 0) \
|
&& (c) >= 0) \
|
||||||
{ \
|
{ \
|
||||||
@@ -150,7 +150,7 @@
|
|||||||
do { \
|
do { \
|
||||||
if (*p_langmap \
|
if (*p_langmap \
|
||||||
&& (condition) \
|
&& (condition) \
|
||||||
&& (!p_lnr || (p_lnr && typebuf_maplen() == 0)) \
|
&& (p_lrm || (!p_lrm && KeyTyped)) \
|
||||||
&& !KeyStuffed \
|
&& !KeyStuffed \
|
||||||
&& (c) >= 0 && (c) < 256) \
|
&& (c) >= 0 && (c) < 256) \
|
||||||
c = langmap_mapchar[c]; \
|
c = langmap_mapchar[c]; \
|
||||||
|
16
src/option.c
16
src/option.c
@@ -1703,6 +1703,13 @@ static struct vimoption options[] =
|
|||||||
(char_u *)&p_lnr, PV_NONE,
|
(char_u *)&p_lnr, PV_NONE,
|
||||||
#else
|
#else
|
||||||
(char_u *)NULL, PV_NONE,
|
(char_u *)NULL, PV_NONE,
|
||||||
|
#endif
|
||||||
|
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
|
||||||
|
{"langremap", "lrm", P_BOOL|P_VI_DEF,
|
||||||
|
#ifdef FEAT_LANGMAP
|
||||||
|
(char_u *)&p_lrm, PV_NONE,
|
||||||
|
#else
|
||||||
|
(char_u *)NULL, PV_NONE,
|
||||||
#endif
|
#endif
|
||||||
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
|
{(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
|
||||||
{"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
|
{"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
|
||||||
@@ -7894,6 +7901,15 @@ set_bool_option(
|
|||||||
compatible_set();
|
compatible_set();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FEAT_LANGMAP
|
||||||
|
if ((int *)varp == &p_lrm)
|
||||||
|
/* 'langremap' -> !'langnoremap' */
|
||||||
|
p_lnr = !p_lrm;
|
||||||
|
else if ((int *)varp == &p_lnr)
|
||||||
|
/* 'langnoremap' -> !'langremap' */
|
||||||
|
p_lrm = !p_lnr;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef FEAT_PERSISTENT_UNDO
|
#ifdef FEAT_PERSISTENT_UNDO
|
||||||
/* 'undofile' */
|
/* 'undofile' */
|
||||||
else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
|
else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
|
||||||
|
@@ -604,6 +604,7 @@ EXTERN char_u *p_km; /* 'keymodel' */
|
|||||||
#ifdef FEAT_LANGMAP
|
#ifdef FEAT_LANGMAP
|
||||||
EXTERN char_u *p_langmap; /* 'langmap'*/
|
EXTERN char_u *p_langmap; /* 'langmap'*/
|
||||||
EXTERN int p_lnr; /* 'langnoremap' */
|
EXTERN int p_lnr; /* 'langnoremap' */
|
||||||
|
EXTERN int p_lrm; /* 'langremap' */
|
||||||
#endif
|
#endif
|
||||||
#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
|
#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
|
||||||
EXTERN char_u *p_lm; /* 'langmenu' */
|
EXTERN char_u *p_lm; /* 'langmenu' */
|
||||||
|
@@ -35,29 +35,73 @@ func Test_map_ctrl_c_visual()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_map_langmap()
|
func Test_map_langmap()
|
||||||
" langmap should not get remapped in insert mode
|
if !has('langmap')
|
||||||
inoremap { FAIL_ilangmap
|
return
|
||||||
set langmap=+{ langnoremap
|
endif
|
||||||
|
|
||||||
|
" check langmap applies in normal mode
|
||||||
|
set langmap=+- nolangremap
|
||||||
|
new
|
||||||
|
call setline(1, ['a', 'b', 'c'])
|
||||||
|
2
|
||||||
|
call assert_equal('b', getline('.'))
|
||||||
|
call feedkeys("+", "xt")
|
||||||
|
call assert_equal('a', getline('.'))
|
||||||
|
|
||||||
|
" check no remapping
|
||||||
|
map x +
|
||||||
|
2
|
||||||
|
call feedkeys("x", "xt")
|
||||||
|
call assert_equal('c', getline('.'))
|
||||||
|
|
||||||
|
" check with remapping
|
||||||
|
set langremap
|
||||||
|
2
|
||||||
|
call feedkeys("x", "xt")
|
||||||
|
call assert_equal('a', getline('.'))
|
||||||
|
|
||||||
|
unmap x
|
||||||
|
bwipe!
|
||||||
|
|
||||||
|
" 'langnoremap' follows 'langremap' and vise versa
|
||||||
|
set langremap
|
||||||
|
set langnoremap
|
||||||
|
call assert_equal(0, &langremap)
|
||||||
|
set langremap
|
||||||
|
call assert_equal(0, &langnoremap)
|
||||||
|
set nolangremap
|
||||||
|
call assert_equal(1, &langnoremap)
|
||||||
|
|
||||||
|
" langmap should not apply in insert mode, 'langremap' doesn't matter
|
||||||
|
set langmap=+{ nolangremap
|
||||||
|
call feedkeys("Go+\<Esc>", "xt")
|
||||||
|
call assert_equal('+', getline('$'))
|
||||||
|
set langmap=+{ langremap
|
||||||
call feedkeys("Go+\<Esc>", "xt")
|
call feedkeys("Go+\<Esc>", "xt")
|
||||||
call assert_equal('+', getline('$'))
|
call assert_equal('+', getline('$'))
|
||||||
|
|
||||||
" Insert-mode expr mapping with langmap
|
" langmap used for register name in insert mode.
|
||||||
inoremap <expr> { "FAIL_iexplangmap"
|
call setreg('a', 'aaaa')
|
||||||
call feedkeys("Go+\<Esc>", "xt")
|
call setreg('b', 'bbbb')
|
||||||
call assert_equal('+', getline('$'))
|
call setreg('c', 'cccc')
|
||||||
iunmap <expr> {
|
set langmap=ab langremap
|
||||||
|
call feedkeys("Go\<C-R>a\<Esc>", "xt")
|
||||||
|
call assert_equal('bbbb', getline('$'))
|
||||||
|
call feedkeys("Go\<C-R>\<C-R>a\<Esc>", "xt")
|
||||||
|
call assert_equal('bbbb', getline('$'))
|
||||||
|
" mapping does not apply
|
||||||
|
imap c a
|
||||||
|
call feedkeys("Go\<C-R>c\<Esc>", "xt")
|
||||||
|
call assert_equal('cccc', getline('$'))
|
||||||
|
imap a c
|
||||||
|
call feedkeys("Go\<C-R>a\<Esc>", "xt")
|
||||||
|
call assert_equal('bbbb', getline('$'))
|
||||||
|
|
||||||
" langmap should not get remapped in Command-line mode
|
" langmap should not apply in Command-line mode
|
||||||
cnoremap { FAIL_clangmap
|
set langmap=+{ nolangremap
|
||||||
call feedkeys(":call append(line('$'), '+')\<CR>", "xt")
|
call feedkeys(":call append(line('$'), '+')\<CR>", "xt")
|
||||||
call assert_equal('+', getline('$'))
|
call assert_equal('+', getline('$'))
|
||||||
cunmap {
|
|
||||||
|
|
||||||
" Command-line mode expr mapping with langmap
|
|
||||||
cnoremap <expr> { "FAIL_cexplangmap"
|
|
||||||
call feedkeys(":call append(line('$'), '+')\<CR>", "xt")
|
|
||||||
call assert_equal('+', getline('$'))
|
|
||||||
cunmap {
|
|
||||||
set nomodified
|
set nomodified
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
@@ -763,6 +763,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
2236,
|
||||||
/**/
|
/**/
|
||||||
2235,
|
2235,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user