To: vim-dev@vim.org Subject: patch 5.5.023 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.5.023 Problem: When editing a new file and autocommands change the cursor position, the cursor was moved back to the first non-white, unless 'startofline' was reset. Solution: Keep the new column, just like the line number. Files: src/ex_cmds.c *** ../vim-5.5.22/src/ex_cmds.c Sat Oct 2 17:33:34 1999 --- src/ex_cmds.c Sun Oct 17 12:40:49 1999 *************** *** 2291,2296 **** --- 2291,2297 ---- long n; linenr_t lnum; linenr_t topline = 0; + int newcol = -1; if (fnum != 0) { *************** *** 2624,2630 **** --- 2625,2634 ---- * keep it. */ if (curwin->w_cursor.lnum != lnum) + { newlnum = curwin->w_cursor.lnum; + newcol = curwin->w_cursor.col; + } if (curwin->w_topline == topline) topline = 0; *************** *** 2635,2653 **** if (command == NULL) { ! if (newlnum > 0) { curwin->w_cursor.lnum = newlnum; check_cursor_lnum(); beginline(BL_SOL | BL_FIX); } ! else { if (exmode_active) - { curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; - check_cursor_lnum(); - } beginline(BL_WHITE | BL_FIX); } } --- 2639,2660 ---- if (command == NULL) { ! if (newcol >= 0) /* position set by autocommands */ ! { ! curwin->w_cursor.lnum = newlnum; ! curwin->w_cursor.col = newcol; ! adjust_cursor(); ! } ! else if (newlnum > 0) /* line number from caller or old position */ { curwin->w_cursor.lnum = newlnum; check_cursor_lnum(); beginline(BL_SOL | BL_FIX); } ! else /* no line number, go to last line in Ex mode */ { if (exmode_active) curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; beginline(BL_WHITE | BL_FIX); } } *** ../vim-5.5.22/src/version.c Tue Oct 12 19:55:31 1999 --- src/version.c Sun Oct 17 12:42:17 1999 *************** *** 420,420 **** --- 420,421 ---- { /* Add new patch number below this line */ + 23, -- TIM: That is not an ordinary rabbit ... 'tis the most foul cruel and bad-tempered thing you ever set eyes on. ROBIN: You tit. I soiled my armour I was so scared! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /