Hi Bram!
On Mo, 29 Sep 2014, Bram Moolenaar wrote:
>
> Christian wrote:
>
> > On Mi, 24 Sep 2014, Gevisz wrote:
> > > Some abbreviations expand as desired and some do not.
> > >
> > > > Are there any circumstances different between a working abbreviation
> > > > and a not working abbreviation?
> > >
> > > They may be very similar. For example, abbreviation чкпк expands as
> > > desired, whereas abbreviation чкпр does not expand at all unless I
> > > redefine it via imaps. (The only difference between чкпк and чкпр is
> > > in the last cyrillic letter.)
> > >
> > > > Have you tried, testing with
> > > > vim -u NONE -N (to eliminate the effect of any plugins)?
> > >
> > > I have just tried that. No abbreviation works after starting vim with
> > > such parameters. However, when I define these two abbreviation anew in
> > > thus started vim, I get the same picture: чкпк abbreviation works and
> > > чкпр one do not.
> >
> > I can reproduce this. Does this always involve the character 'р'?
> >
> > Bram, problem is, 'р' is U+0440 (0xD1 0x80). As you may now already
> > guess, the 0x80 will be parsed as K_SPECIAL and therefore encoded as
> > K_SPECIAL KS_SPECIAL KE_FILLER. Now when checking for an abbreviation,
> > Vim does not consider that the len of the mapped keys might differ from
> > the len of the input chars.
> >
> > Attached patch fixes this.
>
> Thanks. This deserves a test.
>
> > @@ -4517,6 +4519,14 @@ check_abbr(c, ptr, col, mincol)
> > #else
> > mp = first_abbr;
> > #endif
> > + q = vim_strsave(mp->m_keys);
> > + if (q != NULL)
> > + {
> > + /* might have CSI escaped mp->m_keys */
> > + vim_unescape_csi(q);
> > + qlen = STRLEN(q);
> > + vim_free(q);
> > + }
> > for ( ; mp;
>
> The alloc/free is not cheap. Perhaps only do this when 0x80 can be
> found in m_keys?
>
> > /* find entries with right mode and keys */
> > if ( (mp->m_mode & State)
> > - && mp->m_keylen == len
> > + && (mp->m_keylen == len || qlen == len)
> > && !STRNCMP(mp->m_keys, ptr, (size_t)len))
> > break;
>
> Why not only compare with qlen (when initialiing qlen to m_keylen)?
Ok, I think I have addressed all your issues. Here is an update.
Best,
Christian
--
An meinen Bildern müßt ihr nicht schnüffeln, die Farben sind
ungesund.
-- Rembrandt
--
--
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].
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/getchar.c b/src/getchar.c
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -4440,6 +4440,8 @@ check_abbr(c, ptr, col, mincol)
#endif
int is_id = TRUE;
int vim_abbr;
+ char_u *q = NULL;
+ int qlen = 0; /* length of q, CSI/K_SPECIAL unescaped */
if (typebuf.tb_no_abbr_cnt) /* abbrev. are not recursive */
return FALSE;
@@ -4517,6 +4519,18 @@ check_abbr(c, ptr, col, mincol)
#else
mp = first_abbr;
#endif
+ qlen = mp->m_keylen;
+ if (vim_strbyte(mp->m_keys, K_SPECIAL) != NULL)
+ {
+ /* might have CSI escaped mp->m_keys */
+ q = vim_strsave(mp->m_keys);
+ if (q != NULL)
+ {
+ vim_unescape_csi(q);
+ qlen = STRLEN(q);
+ vim_free(q);
+ }
+ }
for ( ; mp;
#ifdef FEAT_LOCALMAP
mp->m_next == NULL ? (mp = mp2, mp2 = NULL) :
@@ -4525,7 +4539,7 @@ check_abbr(c, ptr, col, mincol)
{
/* find entries with right mode and keys */
if ( (mp->m_mode & State)
- && mp->m_keylen == len
+ && qlen == len
&& !STRNCMP(mp->m_keys, ptr, (size_t)len))
break;
}
diff --git a/src/testdir/Make_amiga.mak b/src/testdir/Make_amiga.mak
--- a/src/testdir/Make_amiga.mak
+++ b/src/testdir/Make_amiga.mak
@@ -43,6 +43,7 @@ SCRIPTS = test1.out test3.out test4.out
test_insertcount.out \
test_listlbr.out \
test_listlbr_utf8.out \
+ test_mapping.out \
test_options.out \
test_qf_title.out \
test_utf8.out
diff --git a/src/testdir/Make_dos.mak b/src/testdir/Make_dos.mak
--- a/src/testdir/Make_dos.mak
+++ b/src/testdir/Make_dos.mak
@@ -42,6 +42,7 @@ SCRIPTS = test3.out test4.out test5.out
test_insertcount.out \
test_listlbr.out \
test_listlbr_utf8.out \
+ test_mapping.out \
test_options.out \
test_qf_title.out \
test_utf8.out
diff --git a/src/testdir/Make_ming.mak b/src/testdir/Make_ming.mak
--- a/src/testdir/Make_ming.mak
+++ b/src/testdir/Make_ming.mak
@@ -62,6 +62,7 @@ SCRIPTS = test3.out test4.out test5.out
test_insertcount.out \
test_listlbr.out \
test_listlbr_utf8.out \
+ test_mapping.out \
test_options.out \
test_qf_title.out \
test_utf8.out
diff --git a/src/testdir/Make_os2.mak b/src/testdir/Make_os2.mak
--- a/src/testdir/Make_os2.mak
+++ b/src/testdir/Make_os2.mak
@@ -44,6 +44,7 @@ SCRIPTS = test1.out test3.out test4.out
test_insertcount.out \
test_listlbr.out \
test_listlbr_utf8.out \
+ test_mapping \
test_options.out \
test_qf_title.out \
test_utf8.out
diff --git a/src/testdir/Make_vms.mms b/src/testdir/Make_vms.mms
--- a/src/testdir/Make_vms.mms
+++ b/src/testdir/Make_vms.mms
@@ -103,6 +103,7 @@ SCRIPT = test1.out test2.out test3.out
test_insertcount.out \
test_listlbr.out \
test_listlbr_utf8.out \
+ test_mapping.out \
test_options.out \
test_qf_title.out \
test_utf8.out
diff --git a/src/testdir/Makefile b/src/testdir/Makefile
--- a/src/testdir/Makefile
+++ b/src/testdir/Makefile
@@ -10,6 +10,7 @@ SCRIPTSOURCE = ../../runtime
# Vim should be compiled with EXITFREE to avoid false warnings.
# This will make testing about 10 times as slow.
# VALGRIND = valgrind --tool=memcheck --leak-check=yes --num-callers=15 --log-file=valgrind.$*
+# VALGRIND = gdb --args
SCRIPTS = test1.out test2.out test3.out test4.out test5.out test6.out \
@@ -40,6 +41,7 @@ SCRIPTS = test1.out test2.out test3.out
test_insertcount.out \
test_listlbr.out \
test_listlbr_utf8.out \
+ test_mapping.out \
test_options.out \
test_qf_title.out \
test_utf8.out
diff --git a/src/testdir/test_mapping.in b/src/testdir/test_mapping.in
new file mode 100644
--- /dev/null
+++ b/src/testdir/test_mapping.in
@@ -0,0 +1,15 @@
+Test for mappings and abbreviations
+
+STARTTEST
+:so small.vim
+:so mbyte.vim
+: " abbreviations with Ñ (0x80) should work
+:inoreab ÑÐºÐ¿Ñ vim
+GAÑкпÑ
+
+:/^test/,$w! test.out
+:qa!
+ENDTEST
+
+test starts here:
+
diff --git a/src/testdir/test_mapping.ok b/src/testdir/test_mapping.ok
new file mode 100644
--- /dev/null
+++ b/src/testdir/test_mapping.ok
@@ -0,0 +1,2 @@
+test starts here:
+vim