To: vim-dev@vim.org Subject: Patch 6.1.159 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1.159 Problem: When expanding an abbreviation that includes a multi-byte character too many characters are deleted. (Andrey Urazov) Solution: Delete the abbreviation counting characters instead of bytes. Files: src/getchar.c *** ../vim61.158/src/getchar.c Mon Apr 29 22:57:48 2002 --- src/getchar.c Sun Aug 18 21:25:55 2002 *************** *** 3742,3757 **** int mincol; { int len; int j; char_u tb[4]; mapblock_T *mp; #ifdef FEAT_LOCALMAP mapblock_T *mp2; #endif int is_id = TRUE; int vim_abbr; ! if (typebuf.tb_no_abbr_cnt) /* abbrev. are not recursive */ return FALSE; /* --- 3742,3761 ---- int mincol; { int len; + int scol; /* starting column of the abbr. */ int j; char_u tb[4]; mapblock_T *mp; #ifdef FEAT_LOCALMAP mapblock_T *mp2; #endif + #ifdef FEAT_MBYTE + int clen = 0; /* length in characters */ + #endif int is_id = TRUE; int vim_abbr; ! if (typebuf.tb_no_abbr_cnt) /* abbrev. are not recursive */ return FALSE; /* *************** *** 3777,3782 **** --- 3781,3787 ---- if (p > ptr) is_id = vim_iswordp(mb_prevptr(ptr, p)); } + clen = 1; while (p > ptr) { p = mb_prevptr(ptr, p); *************** *** 3785,3792 **** p += (*mb_ptr2len_check)(p); break; } } ! len = (int)(p - ptr); } else #endif --- 3790,3798 ---- p += (*mb_ptr2len_check)(p); break; } + ++clen; } ! scol = (int)(p - ptr); } else #endif *************** *** 3799,3815 **** if (col > 1) is_id = vim_iswordc(ptr[col - 2]); } ! for (len = col - 1; len > 0 && !vim_isspace(ptr[len - 1]) && ! (vim_abbr || is_id == vim_iswordc(ptr[len - 1])); --len) ; } ! if (len < mincol) ! len = mincol; ! if (len < col) /* there is a word in front of the cursor */ { ! ptr += len; ! len = col - len; #ifdef FEAT_LOCALMAP mp = curbuf->b_first_abbr; mp2 = first_abbr; --- 3805,3821 ---- if (col > 1) is_id = vim_iswordc(ptr[col - 2]); } ! for (scol = col - 1; scol > 0 && !vim_isspace(ptr[scol - 1]) ! && (vim_abbr || is_id == vim_iswordc(ptr[scol - 1])); --scol) ; } ! if (scol < mincol) ! scol = mincol; ! if (scol < col) /* there is a word in front of the cursor */ { ! ptr += scol; ! len = col - scol; #ifdef FEAT_LOCALMAP mp = curbuf->b_first_abbr; mp2 = first_abbr; *************** *** 3849,3855 **** * abbreviation, but is not inserted into the input stream. */ j = 0; ! /* special key code, split up */ if (c != Ctrl_RSB) { if (IS_SPECIAL(c) || c == K_SPECIAL) --- 3855,3861 ---- * abbreviation, but is not inserted into the input stream. */ j = 0; ! /* special key code, split up */ if (c != Ctrl_RSB) { if (IS_SPECIAL(c) || c == K_SPECIAL) *************** *** 3859,3878 **** c = K_THIRD(c); } else if (c < ABBR_OFF && (c < ' ' || c > '~')) ! tb[j++] = Ctrl_V; /* special char needs CTRL-V */ tb[j++] = c; tb[j] = NUL; ! /* insert the last typed char */ (void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent); } ! /* insert the to string */ (void)ins_typebuf(mp->m_str, mp->m_noremap, 0, TRUE, mp->m_silent); ! /* no abbrev. for these chars */ typebuf.tb_no_abbr_cnt += (int)STRLEN(mp->m_str) + j + 1; tb[0] = Ctrl_H; tb[1] = NUL; ! while (len--) /* delete the from string */ (void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent); return TRUE; } --- 3865,3888 ---- c = K_THIRD(c); } else if (c < ABBR_OFF && (c < ' ' || c > '~')) ! tb[j++] = Ctrl_V; /* special char needs CTRL-V */ tb[j++] = c; tb[j] = NUL; ! /* insert the last typed char */ (void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent); } ! /* insert the to string */ (void)ins_typebuf(mp->m_str, mp->m_noremap, 0, TRUE, mp->m_silent); ! /* no abbrev. for these chars */ typebuf.tb_no_abbr_cnt += (int)STRLEN(mp->m_str) + j + 1; tb[0] = Ctrl_H; tb[1] = NUL; ! #ifdef FEAT_MBYTE ! if (has_mbyte) ! len = clen; /* Delete characters instead of bytes */ ! #endif ! while (len-- > 0) /* delete the from string */ (void)ins_typebuf(tb, 1, 0, TRUE, mp->m_silent); return TRUE; } *** ../vim61.158/src/version.c Sun Aug 18 17:18:25 2002 --- src/version.c Sun Aug 18 21:23:03 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 159, /**/ -- hundred-and-one symptoms of being an internet addict: 234. You started college as a chemistry major, and walk out four years later as an Internet provider. /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\ \\\ Project leader for A-A-P -- http://www.a-a-p.org /// \\\ Lord Of The Rings helps Uganda - http://iccf-holland.org/lotr.html ///