summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0333
blob: f4179ce59ff95da17fef8b9305ee1f4e49de6919 (plain)
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
diff --git src/ex_docmd.c src/ex_docmd.c
index d4cf6a2c0..c8a1c3f23 100644
--- src/ex_docmd.c
+++ src/ex_docmd.c
@@ -11706,6 +11706,18 @@ ses_do_win(win_T *wp)
     return TRUE;
 }
 
+    static int
+put_view_curpos(FILE *fd, win_T *wp, char *spaces)
+{
+    int r;
+
+    if (wp->w_curswant == MAXCOL)
+	r = fprintf(fd, "%snormal! $", spaces);
+    else
+	r = fprintf(fd, "%snormal! 0%d|", spaces, wp->w_virtcol + 1);
+    return r < 0 || put_eol(fd) == FAIL ? FALSE : OK;
+}
+
 /*
  * Write commands to "fd" to restore the view of a window.
  * Caller must make sure 'scrolloff' is zero.
@@ -11897,17 +11909,12 @@ put_view(
 			    (long)wp->w_virtcol + 1) < 0
 			|| put_eol(fd) == FAIL
 			|| put_line(fd, "else") == FAIL
-			|| fprintf(fd, "  normal! 0%d|", wp->w_virtcol + 1) < 0
-			|| put_eol(fd) == FAIL
+			|| put_view_curpos(fd, wp, "  ") == FAIL
 			|| put_line(fd, "endif") == FAIL)
 		    return FAIL;
 	    }
-	    else
-	    {
-		if (fprintf(fd, "normal! 0%d|", wp->w_virtcol + 1) < 0
-			|| put_eol(fd) == FAIL)
-		    return FAIL;
-	    }
+	    else if (put_view_curpos(fd, wp, "") == FAIL)
+		return FAIL;
 	}
     }
 
diff --git src/testdir/test_mksession.vim src/testdir/test_mksession.vim
index c0b82ffa8..ed8b10fa0 100644
--- src/testdir/test_mksession.vim
+++ src/testdir/test_mksession.vim
@@ -22,7 +22,8 @@ func Test_mksession()
     \   'two	tabs	in one line',
     \   'one ä multibyteCharacter',
     \   'aä Ä  two multiByte characters',
-    \   'Aäöü  three mulTibyte characters'
+    \   'Aäöü  three mulTibyte characters',
+    \   'short line',
     \ ])
   let tmpfile = 'Xtemp'
   exec 'w! ' . tmpfile
@@ -44,6 +45,8 @@ func Test_mksession()
   norm! j16|
   split
   norm! j16|
+  split
+  norm! j$
   wincmd l
 
   set nowrap
@@ -66,7 +69,7 @@ func Test_mksession()
   split
   call wincol()
   mksession! Xtest_mks.out
-  let li = filter(readfile('Xtest_mks.out'), 'v:val =~# "\\(^ *normal! 0\\|^ *exe ''normal!\\)"')
+  let li = filter(readfile('Xtest_mks.out'), 'v:val =~# "\\(^ *normal! [0$]\\|^ *exe ''normal!\\)"')
   let expected = [
     \   'normal! 016|',
     \   'normal! 016|',
@@ -76,6 +79,7 @@ func Test_mksession()
     \   'normal! 016|',
     \   'normal! 016|',
     \   'normal! 016|',
+    \   'normal! $',
     \   "  exe 'normal! ' . s:c . '|zs' . 16 . '|'",
     \   "  normal! 016|",
     \   "  exe 'normal! ' . s:c . '|zs' . 16 . '|'",
@@ -317,7 +321,7 @@ func Test_mkview_file()
   help :mkview
   set number
   norm! V}zf
-  let pos = getpos('.')
+  let pos = getcurpos()
   let linefoldclosed1 = foldclosed('.')
   mkview! Xview
   set nonumber
@@ -329,7 +333,7 @@ func Test_mkview_file()
   source Xview
   call assert_equal(1, &number)
   call assert_match('\*:mkview\*$', getline('.'))
-  call assert_equal(pos, getpos('.'))
+  call assert_equal(pos, getcurpos())
   call assert_equal(linefoldclosed1, foldclosed('.'))
 
   " Creating a view again with the same file name should fail (file
@@ -352,7 +356,7 @@ func Test_mkview_loadview_with_viewdir()
   help :mkview
   set number
   norm! V}zf
-  let pos = getpos('.')
+  let pos = getcurpos()
   let linefoldclosed1 = foldclosed('.')
   mkview 1
   set nonumber
@@ -369,7 +373,7 @@ func Test_mkview_loadview_with_viewdir()
         \           glob('Xviewdir/*'))
   call assert_equal(1, &number)
   call assert_match('\*:mkview\*$', getline('.'))
-  call assert_equal(pos, getpos('.'))
+  call assert_equal(pos, getcurpos())
   call assert_equal(linefoldclosed1, foldclosed('.'))
 
   call delete('Xviewdir', 'rf')
diff --git src/version.c src/version.c
index 243e213d2..c2f64d37a 100644
--- src/version.c
+++ src/version.c
@@ -795,6 +795,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    333,
+/**/
     332,
 /**/
     331,