Mercurial > vim
comparison src/undo.c @ 28835:58d2315b096e v8.2.4941
patch 8.2.4941: '[ and '] marks may be wrong after undo
Commit: https://github.com/vim/vim/commit/82444cefa3fef87624a078ea86a72af7ef4ef42e
Author: LemonBoy <thatlemon@gmail.com>
Date: Thu May 12 15:39:31 2022 +0100
patch 8.2.4941: '[ and '] marks may be wrong after undo
Problem: '[ and '] marks may be wrong after undo.
Solution: Adjust the '[ and '] marks if needed. (closes https://github.com/vim/vim/issues/10407, closes https://github.com/vim/vim/issues/1281)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 12 May 2022 16:45:03 +0200 |
parents | 4dcccb2673fe |
children | 48d74a5822eb |
comparison
equal
deleted
inserted
replaced
28834:4a4e0b5939b7 | 28835:58d2315b096e |
---|---|
2829 curbuf->b_op_end.lnum += newsize - oldsize; | 2829 curbuf->b_op_end.lnum += newsize - oldsize; |
2830 } | 2830 } |
2831 if (oldsize > 0 || newsize > 0) | 2831 if (oldsize > 0 || newsize > 0) |
2832 changed_lines(top + 1, 0, bot, newsize - oldsize); | 2832 changed_lines(top + 1, 0, bot, newsize - oldsize); |
2833 | 2833 |
2834 // set '[ and '] mark | 2834 // Set the '[ mark. |
2835 if (top + 1 < curbuf->b_op_start.lnum) | 2835 if (top + 1 < curbuf->b_op_start.lnum) |
2836 curbuf->b_op_start.lnum = top + 1; | 2836 curbuf->b_op_start.lnum = top + 1; |
2837 // Set the '] mark. | |
2837 if (newsize == 0 && top + 1 > curbuf->b_op_end.lnum) | 2838 if (newsize == 0 && top + 1 > curbuf->b_op_end.lnum) |
2838 curbuf->b_op_end.lnum = top + 1; | 2839 curbuf->b_op_end.lnum = top + 1; |
2839 else if (top + newsize > curbuf->b_op_end.lnum) | 2840 else if (top + newsize > curbuf->b_op_end.lnum) |
2840 curbuf->b_op_end.lnum = top + newsize; | 2841 curbuf->b_op_end.lnum = top + newsize; |
2841 | 2842 |
2850 */ | 2851 */ |
2851 nuep = uep->ue_next; | 2852 nuep = uep->ue_next; |
2852 uep->ue_next = newlist; | 2853 uep->ue_next = newlist; |
2853 newlist = uep; | 2854 newlist = uep; |
2854 } | 2855 } |
2856 | |
2857 // Ensure the '[ and '] marks are within bounds. | |
2858 if (curbuf->b_op_start.lnum > curbuf->b_ml.ml_line_count) | |
2859 curbuf->b_op_start.lnum = curbuf->b_ml.ml_line_count; | |
2860 if (curbuf->b_op_end.lnum > curbuf->b_ml.ml_line_count) | |
2861 curbuf->b_op_end.lnum = curbuf->b_ml.ml_line_count; | |
2855 | 2862 |
2856 // Set the cursor to the desired position. Check that the line is valid. | 2863 // Set the cursor to the desired position. Check that the line is valid. |
2857 curwin->w_cursor = new_curpos; | 2864 curwin->w_cursor = new_curpos; |
2858 check_cursor_lnum(); | 2865 check_cursor_lnum(); |
2859 | 2866 |