To: vim-dev@vim.org Subject: Patch 6.1b.012 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.1b.012 Problem: Multi-byte: When 'showbreak' is set and a double-wide character doesn't fit at the right window edge the cursor gets stuck there. Using cursor-left gets stuck when 'virtualedit' is set. (Eric Long) Solution: Fix the way the extra ">" character is counted when 'showbreak' is set. Don't correct cursor for virtual editing on a double-wide character. Files: src/charset.c, src/edit.c *** ../vim61b.011/src/charset.c Fri Feb 22 16:53:26 2002 --- src/charset.c Thu Mar 14 20:35:56 2002 *************** *** 928,933 **** --- 928,938 ---- colnr_T col2; colnr_T colmax; int added; + # ifdef FEAT_MBYTE + int mb_added = 0; + # else + # define mb_added 0 + # endif int numberextra; char_u *ps; int tab_corr = (*s == TAB); *************** *** 1002,1007 **** --- 1007,1020 ---- } } } + # ifdef FEAT_MBYTE + else if (has_mbyte && size == 2 && MB_BYTE2LEN(*s) > 1 + && wp->w_p_wrap && in_win_border(wp, col)) + { + ++size; /* Count the ">" in the last column. */ + mb_added = 1; + } + # endif /* * May have to add something for 'showbreak' string at start of line *************** *** 1011,1017 **** if (*p_sbr != NUL && wp->w_p_wrap && col != 0) { numberextra = win_col_off(wp); ! col += numberextra; if (col >= (colnr_T)W_WIDTH(wp)) { col -= W_WIDTH(wp); --- 1024,1030 ---- if (*p_sbr != NUL && wp->w_p_wrap && col != 0) { numberextra = win_col_off(wp); ! col += numberextra + mb_added; if (col >= (colnr_T)W_WIDTH(wp)) { col -= W_WIDTH(wp); *************** *** 1031,1037 **** } } if (headp != NULL) ! *headp = added; return size; #endif } --- 1044,1050 ---- } } if (headp != NULL) ! *headp = added + mb_added; return size; #endif } *** ../vim61b.011/src/edit.c Sat Mar 9 16:20:03 2002 --- src/edit.c Wed Mar 13 21:12:03 2002 *************** *** 4485,4491 **** if (virtual_active()) { int width; - char_u *ptr; int v = getviscol(); if (v == 0) --- 4485,4490 ---- *************** *** 4497,4514 **** for (;;) { coladvance(v - width); ! if (*p_sbr == NUL || getviscol() < v) break; ++width; } # else coladvance(v - 1); - # endif ! /* Adjust for multi-wide char (not include TAB) */ ! ptr = ml_get_cursor(); ! if (*ptr != TAB && *ptr != NUL && (width = ptr2cells(ptr)) > 1) ! coladvance(v - width); curwin->w_set_curswant = TRUE; return OK; --- 4496,4523 ---- for (;;) { coladvance(v - width); ! /* getviscol() is slow, skip it when 'showbreak' is empty and ! * there are no multi-byte characters */ ! if ((*p_sbr == NUL ! # ifdef FEAT_MBYTE ! && !has_mbyte ! # endif ! ) || getviscol() < v) break; ++width; } # else coladvance(v - 1); ! { ! char_u *ptr; ! ! /* Adjust for multi-wide char (not a TAB) */ ! ptr = ml_get_cursor(); ! if (*ptr != TAB && *ptr != NUL && (width = ptr2cells(ptr)) > 1) ! coladvance(v - width); ! } ! # endif curwin->w_set_curswant = TRUE; return OK; *** ../vim61b.011/src/version.c Fri Mar 15 21:40:01 2002 --- src/version.c Fri Mar 15 21:44:11 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 12, /**/ -- Q: How does a UNIX Guru pick up a girl? A: look; grep; which; eval; nice; uname; talk; date; /// 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 /// \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///