To: vim-dev@vim.org Subject: patch 5.4.49 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.4.49 Problem: When pasting text with [ , the cursor could end up after the last character of the line. Solution: Correct the cursor position for the change in indent. Files: src/ops.c *** ../vim-5.4.48/src/ops.c Sat Aug 21 21:51:34 1999 --- src/ops.c Fri Aug 27 22:29:45 1999 *************** *** 2360,2365 **** --- 2360,2366 ---- int orig_indent = 0; /* init for gcc */ int indent_diff = 0; /* init for gcc */ int first_indent = TRUE; + int lendiff = 0; FPOS old_pos; struct block_def bd; char_u *insert_string = NULL; *************** *** 2747,2752 **** --- 2748,2755 ---- old_pos = curwin->w_cursor; curwin->w_cursor.lnum = lnum; ptr = ml_get(lnum); + if (count == 0 && i == y_size - 1) + lendiff = STRLEN(ptr); #if defined(SMARTINDENT) || defined(CINDENT) if (*ptr == '#' # ifdef SMARTINDENT *************** *** 2771,2776 **** --- 2774,2782 ---- indent = 0; set_indent(indent, TRUE); curwin->w_cursor = old_pos; + /* remember how many chars were removed */ + if (count == 0 && i == y_size - 1) + lendiff -= STRLEN(ml_get(lnum)); } ++nr_lines; } *************** *** 2778,2784 **** /* put '] mark at last inserted character */ curbuf->b_op_end.lnum = lnum; ! col = STRLEN(y_array[y_size - 1]); if (col > 1) curbuf->b_op_end.col = col - 1; else --- 2784,2791 ---- /* put '] mark at last inserted character */ curbuf->b_op_end.lnum = lnum; ! /* correct length for change in indent */ ! col = STRLEN(y_array[y_size - 1]) - lendiff; if (col > 1) curbuf->b_op_end.col = col - 1; else *** ../vim-5.4.48/src/version.h Fri Aug 27 22:45:07 1999 --- src/version.h Fri Aug 27 22:45:48 1999 *************** *** 19,26 **** #define VIM_VERSION_MINOR_STR "4" #define VIM_VERSION_BUILD 57 #define VIM_VERSION_BUILD_STR "57" ! #define VIM_VERSION_PATCHLEVEL 48 ! #define VIM_VERSION_PATCHLEVEL_STR "48" /* * VIM_VERSION_NODOT is used for the runtime directory name. --- 19,26 ---- #define VIM_VERSION_MINOR_STR "4" #define VIM_VERSION_BUILD 57 #define VIM_VERSION_BUILD_STR "57" ! #define VIM_VERSION_PATCHLEVEL 49 ! #define VIM_VERSION_PATCHLEVEL_STR "49" /* * VIM_VERSION_NODOT is used for the runtime directory name. *************** *** 30,35 **** */ #define VIM_VERSION_NODOT "vim54" #define VIM_VERSION_SHORT "5.4" ! #define VIM_VERSION_MEDIUM "5.4.48" ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.48 (1999 Aug 27)" ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.48 (1999 Aug 27, compiled " --- 30,35 ---- */ #define VIM_VERSION_NODOT "vim54" #define VIM_VERSION_SHORT "5.4" ! #define VIM_VERSION_MEDIUM "5.4.49" ! #define VIM_VERSION_LONG "VIM - Vi IMproved 5.4.49 (1999 Aug 27)" ! #define VIM_VERSION_LONG_DATE "VIM - Vi IMproved 5.4.49 (1999 Aug 27, compiled " -- A bug in the hand is better than one as yet undetected. --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /