// vi-compatible way.
if (has_mbyte)
{
- int first, last;
- int same = -1;
- char_u *p_char;
-
- p = keys;
- p_char = mb_unescape(&p);
- if (p_char == NULL)
- p_char = p++;
- first = vim_iswordp(p_char);
+ int first, last;
+ int same = -1;
+ char_u keys_unescaped[MAXMAPLEN + 1];
+ size_t keys_unescaped_len;
+
+ mch_memmove(keys_unescaped, keys, (size_t)(len + 1));
+ keys_unescaped_len = vim_unescape_csi(keys_unescaped);
+ p = keys_unescaped;
+
+ first = vim_iswordp(p);
last = first;
+ MB_PTR_ADV(p);
n = 1;
- while (p < keys + len)
+ while (p < keys_unescaped + keys_unescaped_len)
{
- ++n; // nr of (multi-byte) chars
- p_char = mb_unescape(&p);
- if (p_char == NULL)
- p_char = p++;
- last = vim_iswordp(p_char); // type of last char
+ ++n; // nr of (multi-byte) chars
+ last = vim_iswordp(p); // type of last char
if (same == -1 && last != first)
- same = n - 1; // count of same char type
+ same = n - 1; // count of same char type
+ MB_PTR_ADV(p);
}
if (last && n > 2 && same >= 0 && same < n - 1)
{
if (qe != NULL)
{
q = qe;
- vim_unescape_csi(q);
- qlen = (int)STRLEN(q);
+ qlen = (int)vim_unescape_csi(q);
}
}
/*
* Remove escaping from CSI and K_SPECIAL characters. Reverse of
* vim_strsave_escape_csi(). Works in-place.
+ * Returns the number of bytes in the unescaped string.
*/
- void
+ size_t
vim_unescape_csi(char_u *p)
{
char_u *s = p, *d = p;
*d++ = *s++;
}
*d = NUL;
+ return (size_t)(d - p);
}
/*
int check_abbr(int c, char_u *ptr, int col, int mincol);
char_u *eval_map_expr(mapblock_T *mp, int c);
char_u *vim_strsave_escape_csi(char_u *p);
-void vim_unescape_csi(char_u *p);
+size_t vim_unescape_csi(char_u *p);
int makemap(FILE *fd, buf_T *buf);
int put_escstr(FILE *fd, char_u *strstart, int what);
void check_map_keycodes(void);
iunab abc;
iunab ;
+ " abbreviation with composing chars (end-id)
+ inoreab ..ã a^~
+ inoreab ..β̃ β^~
+ inoreab ..π̃ π^~
+ inoreab ..Λ̃ Λ^~
+ call feedkeys("Go..ã ..β̃ ..π̃ ..Λ̃ \<Esc>", "xt")
+ call assert_equal('a^~ β^~ π^~ Λ^~ ', getline('$'))
+ iunab ..ã
+ iunab ..β̃
+ iunab ..π̃
+ iunab ..Λ̃
+
bwipe!
endfunc