comparison src/undo.c @ 2289:3331756e4232 vim73

Make synstack() work on the character just after the end of the line.
author Bram Moolenaar <bram@vim.org>
date Thu, 08 Jul 2010 22:27:55 +0200
parents 4dda2bd944e1
children ccda151dde4e
comparison
equal deleted inserted replaced
2288:4dda2bd944e1 2289:3331756e4232
231 } 231 }
232 232
233 /* 233 /*
234 * Save the lines between "top" and "bot" for both the "u" and "U" command. 234 * Save the lines between "top" and "bot" for both the "u" and "U" command.
235 * "top" may be 0 and bot may be curbuf->b_ml.ml_line_count + 1. 235 * "top" may be 0 and bot may be curbuf->b_ml.ml_line_count + 1.
236 * Careful: may trigger autocommands that reload the buffer.
236 * Returns FAIL when lines could not be saved, OK otherwise. 237 * Returns FAIL when lines could not be saved, OK otherwise.
237 */ 238 */
238 int 239 int
239 u_save(top, bot) 240 u_save(top, bot)
240 linenr_T top, bot; 241 linenr_T top, bot;
253 } 254 }
254 255
255 /* 256 /*
256 * Save the line "lnum" (used by ":s" and "~" command). 257 * Save the line "lnum" (used by ":s" and "~" command).
257 * The line is replaced, so the new bottom line is lnum + 1. 258 * The line is replaced, so the new bottom line is lnum + 1.
259 * Careful: may trigger autocommands that reload the buffer.
260 * Returns FAIL when lines could not be saved, OK otherwise.
258 */ 261 */
259 int 262 int
260 u_savesub(lnum) 263 u_savesub(lnum)
261 linenr_T lnum; 264 linenr_T lnum;
262 { 265 {
267 } 270 }
268 271
269 /* 272 /*
270 * A new line is inserted before line "lnum" (used by :s command). 273 * A new line is inserted before line "lnum" (used by :s command).
271 * The line is inserted, so the new bottom line is lnum + 1. 274 * The line is inserted, so the new bottom line is lnum + 1.
275 * Careful: may trigger autocommands that reload the buffer.
276 * Returns FAIL when lines could not be saved, OK otherwise.
272 */ 277 */
273 int 278 int
274 u_inssub(lnum) 279 u_inssub(lnum)
275 linenr_T lnum; 280 linenr_T lnum;
276 { 281 {
282 287
283 /* 288 /*
284 * Save the lines "lnum" - "lnum" + nlines (used by delete command). 289 * Save the lines "lnum" - "lnum" + nlines (used by delete command).
285 * The lines are deleted, so the new bottom line is lnum, unless the buffer 290 * The lines are deleted, so the new bottom line is lnum, unless the buffer
286 * becomes empty. 291 * becomes empty.
292 * Careful: may trigger autocommands that reload the buffer.
293 * Returns FAIL when lines could not be saved, OK otherwise.
287 */ 294 */
288 int 295 int
289 u_savedel(lnum, nlines) 296 u_savedel(lnum, nlines)
290 linenr_T lnum; 297 linenr_T lnum;
291 long nlines; 298 long nlines;
331 return TRUE; 338 return TRUE;
332 } 339 }
333 340
334 /* 341 /*
335 * Common code for various ways to save text before a change. 342 * Common code for various ways to save text before a change.
343 * "top" is the line above the first changed line.
344 * "bot" is the line below the last changed line.
345 * Careful: may trigger autocommands that reload the buffer.
346 * Returns FAIL when lines could not be saved, OK otherwise.
336 */ 347 */
337 static int 348 static int
338 u_savecommon(top, bot, newbot) 349 u_savecommon(top, bot, newbot)
339 linenr_T top, bot; 350 linenr_T top, bot;
340 linenr_T newbot; 351 linenr_T newbot;
381 * warning for a read-only file before making the change, so that the 392 * warning for a read-only file before making the change, so that the
382 * FileChangedRO event can replace the buffer with a read-write version 393 * FileChangedRO event can replace the buffer with a read-write version
383 * (e.g., obtained from a source control system). 394 * (e.g., obtained from a source control system).
384 */ 395 */
385 change_warning(0); 396 change_warning(0);
397 if (bot > curbuf->b_ml.ml_line_count + 1)
398 {
399 /* This happens when the FileChangedRO autocommand changes the file in
400 * a way it becomes shorter. */
401 EMSG(_("E834: Line count changed unexpectedly"));
402 return FAIL;
403 }
386 #endif 404 #endif
387 405
388 size = bot - top - 1; 406 size = bot - top - 1;
389 407
390 /* 408 /*
3163 3181
3164 /* 3182 /*
3165 * Implementation of the "U" command. 3183 * Implementation of the "U" command.
3166 * Differentiation from vi: "U" can be undone with the next "U". 3184 * Differentiation from vi: "U" can be undone with the next "U".
3167 * We also allow the cursor to be in another line. 3185 * We also allow the cursor to be in another line.
3186 * Careful: may trigger autocommands that reload the buffer.
3168 */ 3187 */
3169 void 3188 void
3170 u_undoline() 3189 u_undoline()
3171 { 3190 {
3172 colnr_T t; 3191 colnr_T t;