To: vim-dev@vim.org Subject: Patch 6.0.198 Fcc: outbox From: Bram Moolenaar MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit ------------ Patch 6.0.198 Problem: When 'virtualedit' is set and 'showbreak' is not empty, moving the cursor over the line break doesn't work properly. (Eric Long) Solution: Make getviscol() and getviscol2() use getvvcol() to obtain the virtual cursor position. Adjust coladvance() and oneleft() to skip over the 'showbreak' characters. Files: src/edit.c, src/misc2.c *** ../vim60.197/src/edit.c Mon Feb 4 10:31:31 2002 --- src/edit.c Thu Feb 7 15:39:14 2002 *************** *** 4478,4484 **** --- 4478,4497 ---- if (v == 0) return FAIL; + # ifdef FEAT_LINEBREAK + /* We might get stuck on 'showbreak', skip over it. */ + width = 1; + 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) *** ../vim60.197/src/misc2.c Mon Feb 4 22:41:08 2002 --- src/misc2.c Thu Feb 7 15:01:05 2002 *************** *** 38,69 **** int getviscol() { ! int x = 0; ! char_u *line = ml_get_curline(); ! char_u *p; ! for (p = line; (colnr_T)(p - line) < curwin->w_cursor.col; ) ! x += lbr_chartabsize_adv(&p, x); ! ! return x + curwin->w_cursor.coladd; } /* ! * Get the screen position of character col with a coladd. */ int getviscol2(col, coladd) colnr_T col; colnr_T coladd; { ! int x = 0; ! char_u *line = ml_get_curline(); ! char_u *p; ! ! for (p = line; (colnr_T)(p - line) < col; ) ! x += lbr_chartabsize_adv(&p, x); ! return x + coladd; } /* --- 38,65 ---- int getviscol() { ! colnr_T x; ! getvvcol(curwin, &curwin->w_cursor, &x, NULL, NULL); ! return (int)x; } /* ! * Get the screen position of character col with a coladd in the cursor line. */ int getviscol2(col, coladd) colnr_T col; colnr_T coladd; { ! colnr_T x; ! pos_T pos; ! pos.lnum = curwin->w_cursor.lnum; ! pos.col = col; ! pos.coladd = coladd; ! getvvcol(curwin, &pos, &x, NULL, NULL); ! return (int)x; } /* *************** *** 138,143 **** --- 134,142 ---- colnr_T col = 0; int csize = 0; int one_more; + #ifdef FEAT_LINEBREAK + int head = 0; + #endif one_more = (State & INSERT) || restart_edit != NUL #ifdef FEAT_VISUAL *************** *** 146,154 **** ; line = ml_get_curline(); - /* The difference between wcol and col will be used to set coladd - * and insert spaces. - */ if (wcol >= MAXCOL) { idx = (int)STRLEN(line) - 1 + one_more; --- 145,150 ---- *************** *** 193,199 **** --- 189,205 ---- while (col <= wcol && *ptr != NUL) { /* Count a tab for what it's worth (if list mode not on) */ + #ifdef FEAT_LINEBREAK + csize = win_lbr_chartabsize(curwin, ptr, col, &head); + # ifdef FEAT_MBYTE + if (has_mbyte) + ptr += (*mb_ptr2len_check)(ptr); + else + # endif + ++ptr; + #else csize = lbr_chartabsize_adv(&ptr, col); + #endif col += csize; } idx = (int)(ptr - line); *************** *** 206,218 **** if (col > wcol || (!virtual_active() && one_more == 0)) { idx -= 1; col -= csize; } #ifdef FEAT_VIRTUALEDIT ! if (virtual_active() && addspaces && ((col != wcol && col != wcol + 1) || csize > 1)) { if (line[idx] == NUL) { /* Append spaces */ --- 212,232 ---- if (col > wcol || (!virtual_active() && one_more == 0)) { idx -= 1; + # ifdef FEAT_LINEBREAK + /* Don't count the chars from 'showbreak'. */ + csize -= head; + # endif col -= csize; } #ifdef FEAT_VIRTUALEDIT ! if (virtual_active() ! && addspaces && ((col != wcol && col != wcol + 1) || csize > 1)) { + /* 'virtualedit' is set: The difference between wcol and col is + * filled with spaces. */ + if (line[idx] == NUL) { /* Append spaces */ *************** *** 284,291 **** int a = col; int b = wcol - a; ! /* modify the real cursor position to make the cursor appear at ! * the wanted column */ if (b > 0 && b < (MAXCOL - 2 * W_WIDTH(curwin))) pos->coladd = b; --- 298,305 ---- int a = col; int b = wcol - a; ! /* 'virtualedit' is set: The difference between wcol and col is used ! * to set coladd. */ if (b > 0 && b < (MAXCOL - 2 * W_WIDTH(curwin))) pos->coladd = b; *** ../vim60.197/src/version.c Thu Feb 7 12:49:18 2002 --- src/version.c Thu Feb 7 15:08:27 2002 *************** *** 608,609 **** --- 608,611 ---- { /* Add new patch number below this line */ + /**/ + 198, /**/ -- In war we're tough and able. Quite indefatigable Between our quests We sequin vests And impersonate Clark Gable It's a busy life in Camelot. I have to push the pram a lot. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net \\\ ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim ))) \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///