4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: When a ")" or word movement command moves the cursor back from the
12 end of the line it may end up on the trail byte of a multi-byte
13 character. It's also moved back when it isn't needed.
14 Solution: Add the adjust_cursor() function.
18 *** ../vim-7.1.219/src/normal.c Sun Jan 6 20:05:36 2008
19 --- src/normal.c Sat Jan 12 17:10:14 2008
23 static void nv_bck_word __ARGS((cmdarg_T *cap));
24 static void nv_wordcmd __ARGS((cmdarg_T *cap));
25 static void nv_beginline __ARGS((cmdarg_T *cap));
26 + static void adjust_cursor __ARGS((oparg_T *oap));
28 static void adjust_for_sel __ARGS((cmdarg_T *cap));
29 static int unadjust_for_sel __ARGS((void));
32 clearopbeep(cap->oap);
35 ! /* Don't leave the cursor on the NUL past a line */
36 ! if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL)
38 ! --curwin->w_cursor.col;
39 ! cap->oap->inclusive = TRUE;
41 #ifdef FEAT_VIRTUALEDIT
42 curwin->w_cursor.coladd = 0;
45 clearopbeep(cap->oap);
48 ! /* Don't leave the cursor on the NUL past end of line. */
49 ! adjust_cursor(cap->oap);
50 #ifdef FEAT_VIRTUALEDIT
51 curwin->w_cursor.coladd = 0;
56 n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP);
58 ! /* Don't leave the cursor on the NUL past a line */
59 ! if (n != FAIL && curwin->w_cursor.col > 0 && gchar_cursor() == NUL)
61 ! --curwin->w_cursor.col;
62 ! cap->oap->inclusive = TRUE;
65 if (n == FAIL && cap->oap->op_type == OP_NOP)
66 clearopbeep(cap->oap);
69 n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP);
71 ! /* Don't leave the cursor on the NUL past the end of line. */
73 ! adjust_cursor(cap->oap);
75 if (n == FAIL && cap->oap->op_type == OP_NOP)
76 clearopbeep(cap->oap);
80 if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)
87 + * Used after a movement command: If the cursor ends up on the NUL after the
88 + * end of the line, may move it back to the last character and make the motion
95 + /* The cursor cannot remain on the NUL when:
96 + * - the column is > 0
97 + * - not in Visual mode or 'selection' is "o"
98 + * - 'virtualedit' is not "all" and not "onemore".
100 + if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL
102 + && (!VIsual_active || *p_sel == 'o')
104 + #ifdef FEAT_VIRTUALEDIT
105 + && !virtual_active() && (ve_flags & VE_ONEMORE) == 0
109 + --curwin->w_cursor.col;
111 + /* prevent cursor from moving on the trail byte */
113 + mb_adjust_cursor();
115 + oap->inclusive = TRUE;
119 *** ../vim-7.1.219/src/version.c Sat Jan 12 16:45:25 2008
120 --- src/version.c Sat Jan 12 17:07:28 2008
124 { /* Add new patch number below this line */
130 A hamburger walks into a bar, and the bartender says: "I'm sorry,
131 but we don't serve food here."
133 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
134 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
135 \\\ download, build and distribute -- http://www.A-A-P.org ///
136 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///