To: vim_dev@googlegroups.com Subject: Patch 7.4.1085 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1085 Problem: The CTRL-A and CTRL-X commands do not update the '[ and '] marks. Solution: (Yukihiro Nakadaira) Files: src/ops.c, src/testdir/test_marks.in, src/testdir/test_marks.ok *** ../vim-7.4.1084/src/ops.c 2016-01-10 14:13:35.846810344 +0100 --- src/ops.c 2016-01-10 20:16:05.220485343 +0100 *************** *** 5382,5387 **** --- 5382,5389 ---- int pos = 0; int bit = 0; int bits = sizeof(unsigned long) * 8; + pos_T startpos; + pos_T endpos; dohex = (vim_strchr(curbuf->b_p_nf, 'x') != NULL); /* "heX" */ dooct = (vim_strchr(curbuf->b_p_nf, 'o') != NULL); /* "Octal" */ *************** *** 5582,5590 **** --- 5584,5595 ---- #endif } curwin->w_cursor.col = col; + if (!did_change) + startpos = curwin->w_cursor; did_change = TRUE; (void)del_char(FALSE); ins_char(firstdigit); + endpos = curwin->w_cursor; curwin->w_cursor.col = col; } else *************** *** 5677,5682 **** --- 5682,5689 ---- * Delete the old number. */ curwin->w_cursor.col = col; + if (!did_change) + startpos = curwin->w_cursor; did_change = TRUE; todel = length; c = gchar_cursor(); *************** *** 5763,5768 **** --- 5770,5776 ---- STRCAT(buf1, buf2); ins_str(buf1); /* insert the new number */ vim_free(buf1); + endpos = curwin->w_cursor; if (lnum < lnume) curwin->w_cursor.col = t.col; else if (did_change && curwin->w_cursor.col) *************** *** 5788,5793 **** --- 5796,5809 ---- if (visual) /* cursor at the top of the selection */ curwin->w_cursor = VIsual; + if (did_change) + { + /* set the '[ and '] marks */ + curbuf->b_op_start = startpos; + curbuf->b_op_end = endpos; + if (curbuf->b_op_end.col > 0) + --curbuf->b_op_end.col; + } return OK; } *** ../vim-7.4.1084/src/testdir/test_marks.in 2015-02-17 13:43:35.562216149 +0100 --- src/testdir/test_marks.in 2016-01-10 20:13:59.353854730 +0100 *************** *** 8,18 **** madduu :let a = string(getpos("'a")) :$put ='Mark after delete-undo-redo-undo: '.a ! :/^\t/,$wq! test.out ENDTEST textline A textline B textline C Results: --- 8,34 ---- madduu :let a = string(getpos("'a")) :$put ='Mark after delete-undo-redo-undo: '.a ! :'' ENDTEST textline A textline B textline C + STARTTEST + :" test that CTRL-A and CTRL-X updates last changed mark '[, ']. + :/^123/ + :execute "normal! \`[v`]rAjwvjw\`[v`]rX" + ENDTEST + + CTRL-A CTRL-X: + 123 123 123 + 123 123 123 + 123 123 123 + + STARTTEST + :g/^STARTTEST/.,/^ENDTEST/d + :wq! test.out + ENDTEST + Results: *** ../vim-7.4.1084/src/testdir/test_marks.ok 2015-02-17 13:43:35.562216149 +0100 --- src/testdir/test_marks.ok 2016-01-10 20:13:59.353854730 +0100 *************** *** 1,6 **** --- 1,16 ---- + Tests for marks. + + textline A textline B textline C + + CTRL-A CTRL-X: + AAA 123 123 + 123 XXXXXXX + XXX 123 123 + + Results: Mark after delete-undo-redo-undo: [0, 15, 2, 0] *** ../vim-7.4.1084/src/version.c 2016-01-10 20:07:57.981777388 +0100 --- src/version.c 2016-01-10 20:21:27.176984314 +0100 *************** *** 743,744 **** --- 743,746 ---- { /* Add new patch number below this line */ + /**/ + 1085, /**/ -- How come wrong numbers are never busy? /// 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 ///