0
0
mirror of https://github.com/vim/vim.git synced 2025-10-03 05:14:07 -04:00

updated for version 7.3.534

Problem:    When using an InsertCharPre autocommand autoindent fails.
Solution:   Proper handling of v:char. (Alexey Radkov)
This commit is contained in:
Bram Moolenaar
2012-06-01 14:57:51 +02:00
parent d2aed44c77
commit 704984ac87
2 changed files with 27 additions and 7 deletions

View File

@@ -10109,21 +10109,39 @@ do_insert_char_pre(c)
int c;
{
char_u *res;
#ifdef FEAT_MBYTE
char_u buf[MB_MAXBYTES + 1];
#else
char_u buf[2];
#endif
/* Return quickly when there is nothing to do. */
if (!has_insertcharpre())
return NULL;
#ifdef FEAT_MBYTE
if (has_mbyte)
buf[(*mb_char2bytes)(c, buf)] = NUL;
else
#endif
{
buf[0] = c;
buf[1] = NUL;
}
/* Lock the text to avoid weird things from happening. */
++textlock;
set_vim_var_char(c); /* set v:char */
set_vim_var_string(VV_CHAR, buf, -1); /* set v:char */
if (apply_autocmds(EVENT_INSERTCHARPRE, NULL, NULL, FALSE, curbuf))
/* Get the new value of v:char. It may be empty or more than one
* character. */
res = vim_strsave(get_vim_var_str(VV_CHAR));
else
res = NULL;
if (apply_autocmds(EVENT_INSERTCHARPRE, NULL, NULL, FALSE, curbuf))
{
/* Get the value of v:char. It may be empty or more than one
* character. Only use it when changed, otherwise continue with the
* original character to avoid breaking autoindent. */
if (STRCMP(buf, get_vim_var_str(VV_CHAR)) != 0)
res = vim_strsave(get_vim_var_str(VV_CHAR));
}
set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */
--textlock;

View File

@@ -714,6 +714,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
534,
/**/
533,
/**/