]> git.pld-linux.org Git - packages/vim.git/blob - 7.1.220
- updated to 7.1.285
[packages/vim.git] / 7.1.220
1 To: vim-dev@vim.org
2 Subject: Patch 7.1.220
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.1.220
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.
15 Files:      src/normal.c
16
17
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
20 ***************
21 *** 150,155 ****
22 --- 150,156 ----
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));
27   #ifdef FEAT_VISUAL
28   static void   adjust_for_sel __ARGS((cmdarg_T *cap));
29   static int    unadjust_for_sel __ARGS((void));
30 ***************
31 *** 6567,6578 ****
32         clearopbeep(cap->oap);
33       else
34       {
35 !       /* Don't leave the cursor on the NUL past a line */
36 !       if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL)
37 !       {
38 !           --curwin->w_cursor.col;
39 !           cap->oap->inclusive = TRUE;
40 !       }
41   #ifdef FEAT_VIRTUALEDIT
42         curwin->w_cursor.coladd = 0;
43   #endif
44 --- 6568,6575 ----
45         clearopbeep(cap->oap);
46       else
47       {
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;
52   #endif
53 ***************
54 *** 8408,8419 ****
55       else
56         n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP);
57   
58 !     /* Don't leave the cursor on the NUL past a line */
59 !     if (n != FAIL && curwin->w_cursor.col > 0 && gchar_cursor() == NUL)
60 !     {
61 !       --curwin->w_cursor.col;
62 !       cap->oap->inclusive = TRUE;
63 !     }
64   
65       if (n == FAIL && cap->oap->op_type == OP_NOP)
66         clearopbeep(cap->oap);
67 --- 8405,8413 ----
68       else
69         n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP);
70   
71 !     /* Don't leave the cursor on the NUL past the end of line. */
72 !     if (n != FAIL)
73 !       adjust_cursor(cap->oap);
74   
75       if (n == FAIL && cap->oap->op_type == OP_NOP)
76         clearopbeep(cap->oap);
77 ***************
78 *** 8426,8431 ****
79 --- 8420,8458 ----
80         if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)
81             foldOpenCursor();
82   #endif
83 +     }
84 + }
85
86 + /*
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
89 +  * inclusive.
90 +  */
91 +     static void
92 + adjust_cursor(oap)
93 +     oparg_T *oap;
94 + {
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".
99 +      */
100 +     if (curwin->w_cursor.col > 0 && gchar_cursor() == NUL
101 + #ifdef FEAT_VISUAL
102 +               && (!VIsual_active || *p_sel == 'o')
103 + #endif
104 + #ifdef FEAT_VIRTUALEDIT
105 +               && !virtual_active() && (ve_flags & VE_ONEMORE) == 0
106 + #endif
107 +               )
108 +     {
109 +       --curwin->w_cursor.col;
110 + #ifdef FEAT_MBYTE
111 +       /* prevent cursor from moving on the trail byte */
112 +       if (has_mbyte)
113 +           mb_adjust_cursor();
114 + #endif
115 +       oap->inclusive = TRUE;
116       }
117   }
118   
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
121 ***************
122 *** 668,669 ****
123 --- 668,671 ----
124   {   /* Add new patch number below this line */
125 + /**/
126 +     220,
127   /**/
128
129 -- 
130 A hamburger walks into a bar, and the bartender says: "I'm sorry,
131 but we don't serve food here."
132
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    ///
This page took 0.029065 seconds and 3 git commands to generate.