]>
Commit | Line | Data |
---|---|---|
c6060300 MT |
1 | To: vim_dev@googlegroups.com |
2 | Subject: Patch 7.3.319 | |
3 | Fcc: outbox | |
4 | From: Bram Moolenaar <Bram@moolenaar.net> | |
5 | Mime-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ------------ | |
9 | ||
10 | Patch 7.3.319 (after 7.3.311) | |
11 | Problem: Redobuff doesn't always include changes of the completion leader. | |
12 | Solution: Insert backspaces as needed. (idea by Taro Muraoka) | |
13 | Files: src/edit.c | |
14 | ||
15 | ||
16 | *** ../vim-7.3.318/src/edit.c 2011-09-14 16:52:02.000000000 +0200 | |
17 | --- src/edit.c 2011-09-21 17:59:10.000000000 +0200 | |
18 | *************** | |
19 | *** 163,168 **** | |
20 | --- 163,169 ---- | |
21 | static void ins_compl_set_original_text __ARGS((char_u *str)); | |
22 | static void ins_compl_addfrommatch __ARGS((void)); | |
23 | static int ins_compl_prep __ARGS((int c)); | |
24 | + static void ins_compl_fixRedoBufForLeader __ARGS((char_u *ptr_arg)); | |
25 | static buf_T *ins_compl_next_buf __ARGS((buf_T *buf, int flag)); | |
26 | #if defined(FEAT_COMPL_FUNC) || defined(FEAT_EVAL) | |
27 | static void ins_compl_add_list __ARGS((list_T *list)); | |
28 | *************** | |
29 | *** 3713,3721 **** | |
30 | * memory that was used, and make sure we can redo the insert. */ | |
31 | if (compl_curr_match != NULL || compl_leader != NULL || c == Ctrl_E) | |
32 | { | |
33 | - char_u *p; | |
34 | - int temp = 0; | |
35 | - | |
36 | /* | |
37 | * If any of the original typed text has been changed, eg when | |
38 | * ignorecase is set, we must add back-spaces to the redo | |
39 | --- 3714,3719 ---- | |
40 | *************** | |
41 | *** 3726,3750 **** | |
42 | */ | |
43 | if (compl_curr_match != NULL && compl_used_match && c != Ctrl_E) | |
44 | ptr = compl_curr_match->cp_str; | |
45 | - else if (compl_leader != NULL) | |
46 | - ptr = compl_leader; | |
47 | else | |
48 | ! ptr = compl_orig_text; | |
49 | ! if (compl_orig_text != NULL) | |
50 | ! { | |
51 | ! p = compl_orig_text; | |
52 | ! for (temp = 0; p[temp] != NUL && p[temp] == ptr[temp]; | |
53 | ! ++temp) | |
54 | ! ; | |
55 | ! #ifdef FEAT_MBYTE | |
56 | ! if (temp > 0) | |
57 | ! temp -= (*mb_head_off)(compl_orig_text, p + temp); | |
58 | ! #endif | |
59 | ! for (p += temp; *p != NUL; mb_ptr_adv(p)) | |
60 | ! AppendCharToRedobuff(K_BS); | |
61 | ! } | |
62 | ! if (ptr != NULL) | |
63 | ! AppendToRedobuffLit(ptr + temp, -1); | |
64 | } | |
65 | ||
66 | #ifdef FEAT_CINDENT | |
67 | --- 3724,3732 ---- | |
68 | */ | |
69 | if (compl_curr_match != NULL && compl_used_match && c != Ctrl_E) | |
70 | ptr = compl_curr_match->cp_str; | |
71 | else | |
72 | ! ptr = NULL; | |
73 | ! ins_compl_fixRedoBufForLeader(ptr); | |
74 | } | |
75 | ||
76 | #ifdef FEAT_CINDENT | |
77 | *************** | |
78 | *** 3834,3839 **** | |
79 | --- 3816,3859 ---- | |
80 | } | |
81 | ||
82 | /* | |
83 | + * Fix the redo buffer for the completion leader replacing some of the typed | |
84 | + * text. This inserts backspaces and appends the changed text. | |
85 | + * "ptr" is the known leader text or NUL. | |
86 | + */ | |
87 | + static void | |
88 | + ins_compl_fixRedoBufForLeader(ptr_arg) | |
89 | + char_u *ptr_arg; | |
90 | + { | |
91 | + int len; | |
92 | + char_u *p; | |
93 | + char_u *ptr = ptr_arg; | |
94 | + | |
95 | + if (ptr == NULL) | |
96 | + { | |
97 | + if (compl_leader != NULL) | |
98 | + ptr = compl_leader; | |
99 | + else | |
100 | + return; /* nothing to do */ | |
101 | + } | |
102 | + if (compl_orig_text != NULL) | |
103 | + { | |
104 | + p = compl_orig_text; | |
105 | + for (len = 0; p[len] != NUL && p[len] == ptr[len]; ++len) | |
106 | + ; | |
107 | + #ifdef FEAT_MBYTE | |
108 | + if (len > 0) | |
109 | + len -= (*mb_head_off)(p, p + len); | |
110 | + #endif | |
111 | + for (p += len; *p != NUL; mb_ptr_adv(p)) | |
112 | + AppendCharToRedobuff(K_BS); | |
113 | + } | |
114 | + else | |
115 | + len = 0; | |
116 | + if (ptr != NULL) | |
117 | + AppendToRedobuffLit(ptr + len, -1); | |
118 | + } | |
119 | + | |
120 | + /* | |
121 | * Loops through the list of windows, loaded-buffers or non-loaded-buffers | |
122 | * (depending on flag) starting from buf and looking for a non-scanned | |
123 | * buffer (other than curbuf). curbuf is special, if it is called with | |
124 | *************** | |
125 | *** 5241,5246 **** | |
126 | --- 5261,5270 ---- | |
127 | else | |
128 | edit_submode = (char_u *)_(CTRL_X_MSG(ctrl_x_mode)); | |
129 | ||
130 | + /* If any of the original typed text has been changed we need to fix | |
131 | + * the redo buffer. */ | |
132 | + ins_compl_fixRedoBufForLeader(NULL); | |
133 | + | |
134 | /* Always add completion for the original text. */ | |
135 | vim_free(compl_orig_text); | |
136 | compl_orig_text = vim_strnsave(line + compl_col, compl_length); | |
137 | *** ../vim-7.3.318/src/version.c 2011-09-21 17:33:49.000000000 +0200 | |
138 | --- src/version.c 2011-09-21 18:21:07.000000000 +0200 | |
139 | *************** | |
140 | *** 711,712 **** | |
141 | --- 711,714 ---- | |
142 | { /* Add new patch number below this line */ | |
143 | + /**/ | |
144 | + 319, | |
145 | /**/ | |
146 | ||
147 | -- | |
148 | hundred-and-one symptoms of being an internet addict: | |
149 | 27. You refer to your age as 3.x. | |
150 | ||
151 | /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ | |
152 | /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ | |
153 | \\\ an exciting new programming language -- http://www.Zimbu.org /// | |
154 | \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |