1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0034
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------
Patch 8.1.0034
Problem: Cursor not restored with ":edit #".
Solution: Don't assume autocommands moved the cursor when it was moved to
the first non-blank.
Files: src/ex_cmds.c, src/testdir/test_edit.vim
*** ../vim-8.1.0033/src/ex_cmds.c 2018-04-10 18:37:19.000000000 +0200
--- src/ex_cmds.c 2018-06-04 20:28:56.647447774 +0200
***************
*** 4193,4203 ****
check_arg_idx(curwin);
/* If autocommands change the cursor position or topline, we should
! * keep it. Also when it moves within a line. */
if (!EQUAL_POS(curwin->w_cursor, orig_pos))
{
! newlnum = curwin->w_cursor.lnum;
! newcol = curwin->w_cursor.col;
}
if (curwin->w_topline == topline)
topline = 0;
--- 4193,4210 ----
check_arg_idx(curwin);
/* If autocommands change the cursor position or topline, we should
! * keep it. Also when it moves within a line. But not when it moves
! * to the first non-blank. */
if (!EQUAL_POS(curwin->w_cursor, orig_pos))
{
! char_u *text = ml_get_curline();
!
! if (curwin->w_cursor.lnum != orig_pos.lnum
! || curwin->w_cursor.col != (int)(skipwhite(text) - text))
! {
! newlnum = curwin->w_cursor.lnum;
! newcol = curwin->w_cursor.col;
! }
}
if (curwin->w_topline == topline)
topline = 0;
*** ../vim-8.1.0033/src/testdir/test_edit.vim 2018-02-09 14:37:30.000000000 +0100
--- src/testdir/test_edit.vim 2018-06-04 20:28:56.647447774 +0200
***************
*** 1387,1389 ****
--- 1387,1403 ----
only
endfunc
+ func Test_edit_alt()
+ " Keeping the cursor line didn't happen when the first line has indent.
+ new
+ call setline(1, [' one', 'two', 'three'])
+ w XAltFile
+ $
+ call assert_equal(3, line('.'))
+ e Xother
+ e #
+ call assert_equal(3, line('.'))
+
+ bwipe XAltFile
+ call delete('XAltFile')
+ endfunc
*** ../vim-8.1.0033/src/version.c 2018-06-04 19:11:06.604648995 +0200
--- src/version.c 2018-06-04 20:31:05.227428478 +0200
***************
*** 763,764 ****
--- 763,766 ----
{ /* Add new patch number below this line */
+ /**/
+ 34,
/**/
--
How To Keep A Healthy Level Of Insanity:
8. Don't use any punctuation marks.
/// 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 ///
|