To: vim_dev@googlegroups.com
Subject: Patch 7.3.534
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 7.3.534 (after 7.3.461)
Problem: When using an InsertCharPre autocommand autoindent fails.
Solution: Proper handling of v:char. (Alexey Radkov)
Files: src/edit.c
*** ../vim-7.3.533/src/edit.c 2012-05-18 16:35:17.000000000 +0200
--- src/edit.c 2012-06-01 14:41:06.000000000 +0200
***************
*** 10108,10129 ****
do_insert_char_pre(c)
int c;
{
! char_u *res;
/* Return quickly when there is nothing to do. */
if (!has_insertcharpre())
return NULL;
/* Lock the text to avoid weird things from happening. */
++textlock;
! set_vim_var_char(c); /* 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;
set_vim_var_string(VV_CHAR, NULL, -1); /* clear v:char */
--textlock;
--- 10108,10147 ----
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_string(VV_CHAR, buf, -1); /* set v:char */
+ 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;
*** ../vim-7.3.533/src/version.c 2012-06-01 13:46:06.000000000 +0200
--- src/version.c 2012-06-01 14:42:19.000000000 +0200
***************
*** 716,717 ****
--- 716,719 ----
{ /* Add new patch number below this line */
+ /**/
+ 534,
/**/
--
hundred-and-one symptoms of being an internet addict:
11. You find yourself typing "com" after every period when using a word
processor.com
/// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///