| To: vim_dev@googlegroups.com |
| Subject: Patch 7.3.768 |
| Fcc: outbox |
| From: Bram Moolenaar <Bram@moolenaar.net> |
| Mime-Version: 1.0 |
| Content-Type: text/plain; charset=UTF-8 |
| Content-Transfer-Encoding: 8bit |
| |
| |
| Patch 7.3.768 |
| Problem: settabvar() and setwinvar() may move the cursor. |
| Solution: Save and restore the cursor position when appropriate. (idea by |
| Yasuhiro Matsumoto) |
| Files: src/edit.c |
| |
| |
| |
| |
| |
| *** 372,377 **** |
| --- 372,379 ---- |
| */ |
| if (cmdchar != 'r' && cmdchar != 'v') |
| { |
| + pos_T save_cursor = curwin->w_cursor; |
| + |
| # ifdef FEAT_EVAL |
| if (cmdchar == 'R') |
| ptr = (char_u *)"r"; |
| |
| *** 382,387 **** |
| --- 384,402 ---- |
| set_vim_var_string(VV_INSERTMODE, ptr, 1); |
| # endif |
| apply_autocmds(EVENT_INSERTENTER, NULL, NULL, FALSE, curbuf); |
| + |
| + /* Since Insert mode was not started yet a call to check_cursor_col() |
| + * may have moved the cursor, especially with the "A" command. */ |
| + if (curwin->w_cursor.col != save_cursor.col |
| + && curwin->w_cursor.lnum == save_cursor.lnum) |
| + { |
| + int save_state = State; |
| + |
| + curwin->w_cursor = save_cursor; |
| + State = INSERT; |
| + check_cursor_col(); |
| + State = save_state; |
| + } |
| } |
| #endif |
| |
| |
| |
| |
| *** 727,728 **** |
| --- 727,730 ---- |
| { /* Add new patch number below this line */ |
| + /**/ |
| + 768, |
| /**/ |
| |
| -- |
| Life would be so much easier if we could just look at the source code. |
| |
| /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ |
| /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ |
| \\\ an exciting new programming language -- http://www.Zimbu.org /// |
| \\\ help me help AIDS victims -- http://ICCF-Holland.org /// |