mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.1.0333: :mkview does not restore cursor properly after "$"
Problem: :mkview does not restore cursor properly after "$". (Dominique
Pelle)
Solution: Position the cursor with "normal! $".
92c1b69641
This commit is contained in:
parent
5c9cd009e1
commit
bd7371f460
@ -9239,6 +9239,18 @@ static int ses_do_win(win_T *wp)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int put_view_curpos(FILE *fd, const 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 ? FAIL : OK;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write commands to "fd" to restore the view of a window.
|
* Write commands to "fd" to restore the view of a window.
|
||||||
* Caller must make sure 'scrolloff' is zero.
|
* Caller must make sure 'scrolloff' is zero.
|
||||||
@ -9405,14 +9417,11 @@ put_view(
|
|||||||
(int64_t)(wp->w_virtcol + 1)) < 0
|
(int64_t)(wp->w_virtcol + 1)) < 0
|
||||||
|| put_eol(fd) == FAIL
|
|| put_eol(fd) == FAIL
|
||||||
|| put_line(fd, "else") == FAIL
|
|| put_line(fd, "else") == FAIL
|
||||||
|| fprintf(fd, " normal! 0%d|", wp->w_virtcol + 1) < 0
|
|| put_view_curpos(fd, wp, " ") == FAIL
|
||||||
|| put_eol(fd) == FAIL
|
|
||||||
|| put_line(fd, "endif") == FAIL)
|
|| put_line(fd, "endif") == FAIL)
|
||||||
return FAIL;
|
return FAIL;
|
||||||
} else {
|
} else if (put_view_curpos(fd, wp, "") == FAIL) {
|
||||||
if (fprintf(fd, "normal! 0%d|", wp->w_virtcol + 1) < 0
|
return FAIL;
|
||||||
|| put_eol(fd) == FAIL)
|
|
||||||
return FAIL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,8 @@ func Test_mksession()
|
|||||||
\ 'two tabs in one line',
|
\ 'two tabs in one line',
|
||||||
\ 'one ä multibyteCharacter',
|
\ 'one ä multibyteCharacter',
|
||||||
\ 'aä Ä two multiByte characters',
|
\ 'aä Ä two multiByte characters',
|
||||||
\ 'Aäöü three mulTibyte characters'
|
\ 'Aäöü three mulTibyte characters',
|
||||||
|
\ 'short line',
|
||||||
\ ])
|
\ ])
|
||||||
let tmpfile = 'Xtemp'
|
let tmpfile = 'Xtemp'
|
||||||
exec 'w! ' . tmpfile
|
exec 'w! ' . tmpfile
|
||||||
@ -41,6 +42,8 @@ func Test_mksession()
|
|||||||
norm! j16|
|
norm! j16|
|
||||||
split
|
split
|
||||||
norm! j16|
|
norm! j16|
|
||||||
|
split
|
||||||
|
norm! j$
|
||||||
wincmd l
|
wincmd l
|
||||||
|
|
||||||
set nowrap
|
set nowrap
|
||||||
@ -63,7 +66,7 @@ func Test_mksession()
|
|||||||
split
|
split
|
||||||
call wincol()
|
call wincol()
|
||||||
mksession! Xtest_mks.out
|
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 = [
|
let expected = [
|
||||||
\ 'normal! 016|',
|
\ 'normal! 016|',
|
||||||
\ 'normal! 016|',
|
\ 'normal! 016|',
|
||||||
@ -73,6 +76,7 @@ func Test_mksession()
|
|||||||
\ 'normal! 016|',
|
\ 'normal! 016|',
|
||||||
\ 'normal! 016|',
|
\ 'normal! 016|',
|
||||||
\ 'normal! 016|',
|
\ 'normal! 016|',
|
||||||
|
\ 'normal! $',
|
||||||
\ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
|
\ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
|
||||||
\ " normal! 016|",
|
\ " normal! 016|",
|
||||||
\ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
|
\ " exe 'normal! ' . s:c . '|zs' . 16 . '|'",
|
||||||
@ -157,7 +161,7 @@ func Test_mkview_file()
|
|||||||
help :mkview
|
help :mkview
|
||||||
set number
|
set number
|
||||||
norm! V}zf
|
norm! V}zf
|
||||||
let pos = getpos('.')
|
let pos = getcurpos()
|
||||||
let linefoldclosed1 = foldclosed('.')
|
let linefoldclosed1 = foldclosed('.')
|
||||||
mkview! Xview
|
mkview! Xview
|
||||||
set nonumber
|
set nonumber
|
||||||
@ -169,7 +173,7 @@ func Test_mkview_file()
|
|||||||
source Xview
|
source Xview
|
||||||
call assert_equal(1, &number)
|
call assert_equal(1, &number)
|
||||||
call assert_match('\*:mkview\*$', getline('.'))
|
call assert_match('\*:mkview\*$', getline('.'))
|
||||||
call assert_equal(pos, getpos('.'))
|
call assert_equal(pos, getcurpos())
|
||||||
call assert_equal(linefoldclosed1, foldclosed('.'))
|
call assert_equal(linefoldclosed1, foldclosed('.'))
|
||||||
|
|
||||||
" Creating a view again with the same file name should fail (file
|
" Creating a view again with the same file name should fail (file
|
||||||
@ -192,7 +196,7 @@ func Test_mkview_loadview_with_viewdir()
|
|||||||
help :mkview
|
help :mkview
|
||||||
set number
|
set number
|
||||||
norm! V}zf
|
norm! V}zf
|
||||||
let pos = getpos('.')
|
let pos = getcurpos()
|
||||||
let linefoldclosed1 = foldclosed('.')
|
let linefoldclosed1 = foldclosed('.')
|
||||||
mkview 1
|
mkview 1
|
||||||
set nonumber
|
set nonumber
|
||||||
@ -209,7 +213,7 @@ func Test_mkview_loadview_with_viewdir()
|
|||||||
\ glob('Xviewdir/*'))
|
\ glob('Xviewdir/*'))
|
||||||
call assert_equal(1, &number)
|
call assert_equal(1, &number)
|
||||||
call assert_match('\*:mkview\*$', getline('.'))
|
call assert_match('\*:mkview\*$', getline('.'))
|
||||||
call assert_equal(pos, getpos('.'))
|
call assert_equal(pos, getcurpos())
|
||||||
call assert_equal(linefoldclosed1, foldclosed('.'))
|
call assert_equal(linefoldclosed1, foldclosed('.'))
|
||||||
|
|
||||||
call delete('Xviewdir', 'rf')
|
call delete('Xviewdir', 'rf')
|
||||||
|
Loading…
Reference in New Issue
Block a user