summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-08-21 17:45:02 +0200
committerBram Moolenaar <Bram@vim.org>2016-08-21 17:45:02 +0200
commit920694c1b60fac8017b8909efcc24f189804a9bb (patch)
treedef5ea232552ca189a8fd9e2f78c93724cf68b17 /src
parent989f592f7ffcbafdc4ec35cee4dc65bd053e2077 (diff)
patch 7.4.2236v7.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.
Diffstat (limited to 'src')
-rw-r--r--src/macros.h4
-rw-r--r--src/option.c16
-rw-r--r--src/option.h1
-rw-r--r--src/testdir/test_mapping.vim74
-rw-r--r--src/version.c2
5 files changed, 80 insertions, 17 deletions
diff --git a/src/macros.h b/src/macros.h
index 28f43a3627..aec1425594 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -135,7 +135,7 @@
do { \
if (*p_langmap \
&& (condition) \
- && (!p_lnr || (p_lnr && typebuf_maplen() == 0)) \
+ && (p_lrm || (!p_lrm && KeyTyped)) \
&& !KeyStuffed \
&& (c) >= 0) \
{ \
@@ -150,7 +150,7 @@
do { \
if (*p_langmap \
&& (condition) \
- && (!p_lnr || (p_lnr && typebuf_maplen() == 0)) \
+ && (p_lrm || (!p_lrm && KeyTyped)) \
&& !KeyStuffed \
&& (c) >= 0 && (c) < 256) \
c = langmap_mapchar[c]; \
diff --git a/src/option.c b/src/option.c
index 1a5cd8e4fb..9f1aaf1d15 100644
--- a/src/option.c
+++ b/src/option.c
@@ -1705,6 +1705,13 @@ static struct vimoption options[] =
(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
+ {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT},
{"laststatus", "ls", P_NUM|P_VI_DEF|P_RALL,
#ifdef FEAT_WINDOWS
(char_u *)&p_ls, PV_NONE,
@@ -7894,6 +7901,15 @@ set_bool_option(
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
/* 'undofile' */
else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
diff --git a/src/option.h b/src/option.h
index c86550fb11..9a5570c2ad 100644
--- a/src/option.h
+++ b/src/option.h
@@ -604,6 +604,7 @@ EXTERN char_u *p_km; /* 'keymodel' */
#ifdef FEAT_LANGMAP
EXTERN char_u *p_langmap; /* 'langmap'*/
EXTERN int p_lnr; /* 'langnoremap' */
+EXTERN int p_lrm; /* 'langremap' */
#endif
#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
EXTERN char_u *p_lm; /* 'langmenu' */
diff --git a/src/testdir/test_mapping.vim b/src/testdir/test_mapping.vim
index a1281eb4d3..66b81cecf8 100644
--- a/src/testdir/test_mapping.vim
+++ b/src/testdir/test_mapping.vim
@@ -35,29 +35,73 @@ func Test_map_ctrl_c_visual()
endfunc
func Test_map_langmap()
- " langmap should not get remapped in insert mode
- inoremap { FAIL_ilangmap
- set langmap=+{ langnoremap
+ if !has('langmap')
+ return
+ 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('$'))
-
- " Insert-mode expr mapping with langmap
- inoremap <expr> { "FAIL_iexplangmap"
+ set langmap=+{ langremap
call feedkeys("Go+\<Esc>", "xt")
call assert_equal('+', getline('$'))
- iunmap <expr> {
- " langmap should not get remapped in Command-line mode
- cnoremap { FAIL_clangmap
+ " langmap used for register name in insert mode.
+ call setreg('a', 'aaaa')
+ call setreg('b', 'bbbb')
+ call setreg('c', 'cccc')
+ 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 apply in Command-line mode
+ set langmap=+{ nolangremap
call feedkeys(":call append(line('$'), '+')\<CR>", "xt")
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
endfunc
diff --git a/src/version.c b/src/version.c
index 65eb6d7c06..8b8653190d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2236,
+/**/
2235,
/**/
2234,