Merge #10033 from janlazo/vim-8.0.1082

vim-patch:8.0.{1082,1497,1498,1513},8.1.{901,1357,1358}
This commit is contained in:
Justin M. Keyes 2019-05-20 10:42:31 +02:00 committed by GitHub
commit 60710dee82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 413 additions and 189 deletions

View File

@ -2097,6 +2097,8 @@ getfperm({fname}) String file permissions of file {fname}
getfsize({fname}) Number size in bytes of file {fname}
getftime({fname}) Number last modification time of file
getftype({fname}) String description of type of file {fname}
getjumplist([{winnr} [, {tabnr}]])
List list of jump list items
getline({lnum}) String line {lnum} of current buffer
getline({lnum}, {end}) List lines {lnum} to {end} of current buffer
getloclist({nr} [, {what}]) List list of location list items
@ -4299,6 +4301,26 @@ getftype({fname}) *getftype()*
systems that support it. On some systems only "dir" and
"file" are returned.
*getjumplist()*
getjumplist([{winnr} [, {tabnr}]])
Returns the |jumplist| for the specified window.
Without arguments use the current window.
With {winnr} only use this window in the current tab page.
{winnr} can also be a |window-ID|.
With {winnr} and {tabnr} use the window in the specified tab
page.
The returned list contains two entries: a list with the jump
locations and the last used jump position number in the list.
Each entry in the jump location list is a dictionary with
the following entries:
bufnr buffer number
col column number
coladd column offset for 'virtualedit'
filename filename if available
lnum line number
*getline()*
getline({lnum} [, {end}])
Without {end} the result is a String, which is line {lnum}

View File

@ -806,6 +806,7 @@ Buffers, windows and the argument list:
getbufinfo() get a list with buffer information
gettabinfo() get a list with tab page information
getwininfo() get a list with window information
getjumplist() get a list of jump list entries
Command line: *command-line-functions*
getcmdline() get the current command line

View File

@ -10051,6 +10051,37 @@ static void f_getftype(typval_T *argvars, typval_T *rettv, FunPtr fptr)
rettv->vval.v_string = type;
}
// "getjumplist()" function
static void f_getjumplist(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
tv_list_alloc_ret(rettv, kListLenMayKnow);
win_T *const wp = find_tabwin(&argvars[0], &argvars[1]);
if (wp == NULL) {
return;
}
cleanup_jumplist(wp, true);
list_T *const l = tv_list_alloc(wp->w_jumplistlen);
tv_list_append_list(rettv->vval.v_list, l);
tv_list_append_number(rettv->vval.v_list, wp->w_jumplistidx);
for (int i = 0; i < wp->w_jumplistlen; i++) {
if (wp->w_jumplist[i].fmark.mark.lnum == 0) {
continue;
}
dict_T *const d = tv_dict_alloc();
tv_list_append_dict(l, d);
tv_dict_add_nr(d, S_LEN("lnum"), wp->w_jumplist[i].fmark.mark.lnum);
tv_dict_add_nr(d, S_LEN("col"), wp->w_jumplist[i].fmark.mark.col);
tv_dict_add_nr(d, S_LEN("coladd"), wp->w_jumplist[i].fmark.mark.coladd);
tv_dict_add_nr(d, S_LEN("bufnr"), wp->w_jumplist[i].fmark.fnum);
if (wp->w_jumplist[i].fname != NULL) {
tv_dict_add_str(d, S_LEN("filename"), (char *)wp->w_jumplist[i].fname);
}
}
}
/*
* "getline(lnum, [end])" function
*/

View File

@ -131,6 +131,7 @@ return {
getfsize={args=1},
getftime={args=1},
getftype={args=1},
getjumplist={args={0, 2}},
getline={args={1, 2}},
getloclist={args={1, 2}},
getmatches={},

View File

@ -1287,9 +1287,9 @@ openscript (
oldcurscript = curscript;
do {
update_topline_cursor(); /* update cursor position and topline */
normal_cmd(&oa, FALSE); /* execute one command */
vpeekc(); /* check for end of file */
update_topline_cursor(); // update cursor position and topline
normal_cmd(&oa, false); // execute one command
vpeekc(); // check for end of file
} while (scriptin[oldcurscript] != NULL);
State = save_State;

View File

@ -214,7 +214,7 @@ pos_T *movemark(int count)
pos_T *pos;
xfmark_T *jmp;
cleanup_jumplist();
cleanup_jumplist(curwin, true);
if (curwin->w_jumplistlen == 0) /* nothing to jump to */
return (pos_T *)NULL;
@ -781,13 +781,11 @@ void ex_jumps(exarg_T *eap)
int i;
char_u *name;
cleanup_jumplist();
/* Highlight title */
cleanup_jumplist(curwin, true);
// Highlight title
MSG_PUTS_TITLE(_("\n jump line col file/text"));
for (i = 0; i < curwin->w_jumplistlen && !got_int; ++i) {
if (curwin->w_jumplist[i].fmark.mark.lnum != 0) {
if (curwin->w_jumplist[i].fmark.fnum == 0)
fname2fnum(&curwin->w_jumplist[i]);
name = fm_getname(&curwin->w_jumplist[i].fmark, 16);
if (name == NULL) /* file name not available */
continue;
@ -1156,53 +1154,67 @@ void mark_col_adjust(
}
}
/*
* When deleting lines, this may create duplicate marks in the
* jumplist. They will be removed here for the current window.
*/
void cleanup_jumplist(void)
// When deleting lines, this may create duplicate marks in the
// jumplist. They will be removed here for the specified window.
// When "loadfiles" is true first ensure entries have the "fnum" field set
// (this may be a bit slow).
void cleanup_jumplist(win_T *wp, bool loadfiles)
{
int i;
int from, to;
to = 0;
for (from = 0; from < curwin->w_jumplistlen; ++from) {
if (curwin->w_jumplistidx == from)
curwin->w_jumplistidx = to;
for (i = from + 1; i < curwin->w_jumplistlen; ++i)
if (curwin->w_jumplist[i].fmark.fnum
== curwin->w_jumplist[from].fmark.fnum
&& curwin->w_jumplist[from].fmark.fnum != 0
&& curwin->w_jumplist[i].fmark.mark.lnum
== curwin->w_jumplist[from].fmark.mark.lnum)
if (loadfiles) {
// If specified, load all the files from the jump list. This is
// needed to properly clean up duplicate entries, but will take some
// time.
for (i = 0; i < wp->w_jumplistlen; i++) {
if ((wp->w_jumplist[i].fmark.fnum == 0)
&& (wp->w_jumplist[i].fmark.mark.lnum != 0)) {
fname2fnum(&wp->w_jumplist[i]);
}
}
}
int to = 0;
for (int from = 0; from < wp->w_jumplistlen; from++) {
if (wp->w_jumplistidx == from) {
wp->w_jumplistidx = to;
}
for (i = from + 1; i < wp->w_jumplistlen; i++) {
if (wp->w_jumplist[i].fmark.fnum
== wp->w_jumplist[from].fmark.fnum
&& wp->w_jumplist[from].fmark.fnum != 0
&& wp->w_jumplist[i].fmark.mark.lnum
== wp->w_jumplist[from].fmark.mark.lnum) {
break;
if (i >= curwin->w_jumplistlen) { // no duplicate
}
}
if (i >= wp->w_jumplistlen) { // no duplicate
if (to != from) {
// Not using curwin->w_jumplist[to++] = curwin->w_jumplist[from] because
// Not using wp->w_jumplist[to++] = wp->w_jumplist[from] because
// this way valgrind complains about overlapping source and destination
// in memcpy() call. (clang-3.6.0, debug build with -DEXITFREE).
curwin->w_jumplist[to] = curwin->w_jumplist[from];
wp->w_jumplist[to] = wp->w_jumplist[from];
}
to++;
} else {
xfree(curwin->w_jumplist[from].fname);
xfree(wp->w_jumplist[from].fname);
}
}
if (curwin->w_jumplistidx == curwin->w_jumplistlen) {
curwin->w_jumplistidx = to;
if (wp->w_jumplistidx == wp->w_jumplistlen) {
wp->w_jumplistidx = to;
}
curwin->w_jumplistlen = to;
wp->w_jumplistlen = to;
// When pointer is below last jump, remove the jump if it matches the current
// line. This avoids useless/phantom jumps. #9805
if (curwin->w_jumplistlen
&& curwin->w_jumplistidx == curwin->w_jumplistlen) {
const xfmark_T *fm_last = &curwin->w_jumplist[curwin->w_jumplistlen - 1];
if (wp->w_jumplistlen
&& wp->w_jumplistidx == wp->w_jumplistlen) {
const xfmark_T *fm_last = &wp->w_jumplist[wp->w_jumplistlen - 1];
if (fm_last->fmark.fnum == curbuf->b_fnum
&& fm_last->fmark.mark.lnum == curwin->w_cursor.lnum) {
&& fm_last->fmark.mark.lnum == wp->w_cursor.lnum) {
xfree(fm_last->fname);
curwin->w_jumplistlen--;
curwin->w_jumplistidx--;
wp->w_jumplistlen--;
wp->w_jumplistidx--;
}
}
}

View File

@ -2739,7 +2739,7 @@ static ShaDaWriteResult shada_write(ShaDaWriteDef *const sd_writer,
// Initialize jump list
const void *jump_iter = NULL;
cleanup_jumplist();
cleanup_jumplist(curwin, false);
setpcmark();
do {
xfmark_T fm;

View File

@ -14,7 +14,6 @@ export NVIM_PRG := $(NVIM_PRG)
export TMPDIR := $(abspath ../../../Xtest-tmpdir)
SCRIPTS_DEFAULT = \
test37.out \
test42.out \
test48.out \
test52.out \

View File

@ -1,116 +0,0 @@
Test for 'scrollbind'. <eralston@computer.org> Do not add a line below!
STARTTEST
:
:set noscrollbind
:set scrollopt=ver,jump
:set scrolloff=2
:set nowrap
:set noequalalways
:set splitbelow
:" TEST using two windows open to one buffer, one extra empty window
:split
:new
t:
:resize 8
/^start of window 1$/
zt:
:set scrollbind
j:
:resize 7
/^start of window 2$/
zt:
:set scrollbind
:" -- start of tests --
:" TEST scrolling down
L5jHyybpr0tHyybpr1tL6jHyybpr2kHyybpr3:
:" TEST scrolling up
tH4kjHtHyybpr4kHyybpr5k3ktHjHyybpr6tHyybpr7:
:" TEST horizontal scrolling
:set scrollopt+=hor
gg"zyyG"zpGt015zly$bp"zpGky$bp"zpG:
k10jH7zhg0y$bp"zpGtHg0y$bp"zpG:
:set scrollopt-=hor
:" ****** tests using two different buffers *****
tj:
:close
t:
:set noscrollbind
:/^start of window 2$/,/^end of window 2$/y
:new
tj4"zpGp:
t/^start of window 1$/
zt:
:set scrollbind
j:
/^start of window 2$/
zt:
:set scrollbind
:" -- start of tests --
:" TEST scrolling down
L5jHyybpr0tHyybpr1tL6jHyybpr2kHyybpr3:
:" TEST scrolling up
tH4kjHtHyybpr4kHyybpr5k3ktHjHyybpr6tHyybpr7:
:" TEST horizontal scrolling
:set scrollopt+=hor
gg"zyyG"zpGt015zly$bp"zpGky$bp"zpG:
k10jH7zhg0y$bp"zpGtHg0y$bp"zpG:
:set scrollopt-=hor
:" TEST syncbind
t:set noscb
ggLj:set noscb
ggL:set scb
t:set scb
GjG:syncbind
HktHjHyybptyybp:
t:set noscb
ggLj:set noscb
ggL:set scb
t:set scb
tGjGt:syncbind
HkjHtHyybptjyybp:
tH3kjHtHyybptjyybp:
:" ***** done with tests *****
:w! test.out " Write contents of this file
:qa!
ENDTEST
start of window 1
. line 01 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 01
. line 02 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02
. line 03 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 03
. line 04 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 04
. line 05 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 05
. line 06 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 06
. line 07 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 07
. line 08 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 08
. line 09 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 09
. line 10 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 10
. line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11
. line 12 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 12
. line 13 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 13
. line 14 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 14
. line 15 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 15
end of window 1
start of window 2
. line 01 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 01
. line 02 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 02
. line 03 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 03
. line 04 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 04
. line 05 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 05
. line 06 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 06
. line 07 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 07
. line 08 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 08
. line 09 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 09
. line 10 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 10
. line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11
. line 12 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 12
. line 13 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 13
. line 14 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 14
. line 15 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 15
. line 16 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 16
end of window 2
end of test37.in (please don't delete this line)

View File

@ -1,33 +0,0 @@
0 line 05 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 05
1 line 05 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 05
2 line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11
3 line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11
4 line 06 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 06
5 line 06 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 06
6 line 02 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 02
7 line 02 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02
56789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02
UTSRQPONMLKJIHGREDCBA9876543210 02
. line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11
. line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11
0 line 05 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 05
1 line 05 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 05
2 line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11
3 line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11
4 line 06 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 06
5 line 06 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 06
6 line 02 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 02
7 line 02 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02
56789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02
UTSRQPONMLKJIHGREDCBA9876543210 02
. line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11
. line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11
. line 16 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 16
:set scrollbind
:set scrollbind
. line 16 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 16
j:
. line 12 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 12

View File

@ -35,7 +35,8 @@ func Test_client_server()
endif
" Takes a short while for the server to be active.
call WaitFor('serverlist() =~ "' . name . '"')
" When using valgrind it takes much longer.
call WaitFor('serverlist() =~ "' . name . '"', 5000)
call assert_match(name, serverlist())
call remote_foreground(name)

View File

@ -0,0 +1,66 @@
" Tests for the jumplist functionality
" Tests for the getjumplist() function
func Test_getjumplist()
if !has("jumplist")
return
endif
%bwipe
clearjumps
call assert_equal([[], 0], getjumplist())
call assert_equal([[], 0], getjumplist(1))
call assert_equal([[], 0], getjumplist(1, 1))
call assert_equal([], getjumplist(100))
call assert_equal([], getjumplist(1, 100))
let lines = []
for i in range(1, 100)
call add(lines, "Line " . i)
endfor
call writefile(lines, "Xtest")
" Jump around and create a jump list
edit Xtest
let bnr = bufnr('%')
normal 50%
normal G
normal gg
let expected = [[
\ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0},
\ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0},
\ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 3]
call assert_equal(expected, getjumplist())
" jumplist doesn't change in between calls
call assert_equal(expected, getjumplist())
" Traverse the jump list and verify the results
5
exe "normal \<C-O>"
call assert_equal(2, getjumplist(1)[1])
exe "normal 2\<C-O>"
call assert_equal(0, getjumplist(1, 1)[1])
exe "normal 3\<C-I>"
call assert_equal(3, getjumplist()[1])
exe "normal \<C-O>"
normal 20%
let expected = [[
\ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0},
\ {'lnum': 50, 'bufnr': bnr, 'col': 0, 'coladd': 0},
\ {'lnum': 5, 'bufnr': bnr, 'col': 0, 'coladd': 0},
\ {'lnum': 100, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 4]
call assert_equal(expected, getjumplist())
" jumplist doesn't change in between calls
call assert_equal(expected, getjumplist())
let l = getjumplist()
call test_garbagecollect_now()
call assert_equal(4, l[1])
clearjumps
call test_garbagecollect_now()
call assert_equal(4, l[1])
call delete("Xtest")
endfunc

View File

@ -30,3 +30,243 @@ func Test_scrollbind()
setl noscrollbind
call assert_equal(0, topLineLeft - topLineRight)
endfunc
" Test for 'scrollbind'
func Test_scrollbind_opt()
new | only
set noscrollbind
set scrollopt=ver,jump scrolloff=2 nowrap noequalalways splitbelow
" Insert the text used for the test
append
start of window 1
. line 01 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 01
. line 02 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02
. line 03 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 03
. line 04 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 04
. line 05 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 05
. line 06 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 06
. line 07 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 07
. line 08 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 08
. line 09 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 09
. line 10 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 10
. line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11
. line 12 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 12
. line 13 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 13
. line 14 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 14
. line 15 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 15
end of window 1
start of window 2
. line 01 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 01
. line 02 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 02
. line 03 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 03
. line 04 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 04
. line 05 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 05
. line 06 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 06
. line 07 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 07
. line 08 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 08
. line 09 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 09
. line 10 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 10
. line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11
. line 12 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 12
. line 13 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 13
. line 14 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 14
. line 15 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 15
. line 16 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 16
end of window 2
.
" Test using two windows open to one buffer, one extra empty window
split
new
wincmd t
resize 8
call search('^start of window 1$')
normal zt
set scrollbind
wincmd j
resize 7
call search('^start of window 2$')
normal zt
set scrollbind
" -- start of tests --
" Test scrolling down
normal L5jHyy
wincmd b | normal pr0
wincmd t | normal Hyy
wincmd b | normal pr1
wincmd t | normal L6jHyy
wincmd b | normal pr2
wincmd k | normal Hyy
wincmd b | normal pr3
" Test scrolling up
wincmd t | normal H4k
wincmd j | normal H
wincmd t | normal Hyy
wincmd b | normal pr4
wincmd k | normal Hyy
wincmd b | normal pr5
wincmd k | normal 3k
wincmd t | normal H
wincmd j | normal Hyy
wincmd b | normal pr6
wincmd t | normal Hyy
wincmd b | normal pr7
" Test horizontal scrolling
set scrollopt+=hor
normal gg"zyyG"zpG
wincmd t | normal 015zly$
wincmd b | normal p"zpG
wincmd k | normal y$
wincmd b | normal p"zpG
wincmd k | normal 10jH7zhg0y$
wincmd b | normal p"zpG
wincmd t | normal Hg0y$
wincmd b | normal p"zpG
set scrollopt-=hor
wincmd b
call assert_equal([
\ '',
\ '0 line 05 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 05',
\ '1 line 05 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 05',
\ '2 line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11',
\ '3 line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11',
\ '4 line 06 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 06',
\ '5 line 06 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 06',
\ '6 line 02 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 02',
\ '7 line 02 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02',
\ '56789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02',
\ 'UTSRQPONMLKJIHGREDCBA9876543210 02',
\ '. line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11',
\ '. line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11',
\ ''], getline(1, '$'))
enew!
" ****** tests using two different buffers *****
wincmd t | wincmd j | close
wincmd t | set noscrollbind
/start of window 2$/,/^end of window 2$/y
new
wincmd t | wincmd j | normal 4"zpGp
wincmd t
call search('^start of window 1$')
normal zt
set scrollbind
wincmd j
call search('^start of window 2$')
normal zt
set scrollbind
" -- start of tests --
" Test scrolling down
normal L5jHyy
wincmd b | normal pr0
wincmd t | normal Hyy
wincmd b | normal pr1
wincmd t | normal L6jHyy
wincmd b | normal pr2
wincmd k | normal Hyy
wincmd b | normal pr3
" Test scrolling up
wincmd t | normal H4k
wincmd j | normal H
wincmd t | normal Hyy
wincmd b | normal pr4
wincmd k | normal Hyy
wincmd b | normal pr5
wincmd k | normal 3k
wincmd t | normal H
wincmd j | normal Hyy
wincmd b | normal pr6
wincmd t | normal Hyy
wincmd b | normal pr7
" Test horizontal scrolling
set scrollopt+=hor
normal gg"zyyG"zpG
wincmd t | normal 015zly$
wincmd b | normal p"zpG
wincmd k | normal y$
wincmd b | normal p"zpG
wincmd k | normal 10jH7zhg0y$
wincmd b | normal p"zpG
wincmd t | normal Hg0y$
wincmd b | normal p"zpG
set scrollopt-=hor
wincmd b
call assert_equal([
\ '',
\ '0 line 05 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 05',
\ '1 line 05 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 05',
\ '2 line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11',
\ '3 line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11',
\ '4 line 06 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 06',
\ '5 line 06 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 06',
\ '6 line 02 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 02',
\ '7 line 02 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02',
\ '56789ABCDEFGHIJKLMNOPQRSTUVWXYZ 02',
\ 'UTSRQPONMLKJIHGREDCBA9876543210 02',
\ '. line 11 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 11',
\ '. line 11 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 11',
\ ''], getline(1, '$'))
enew!
" Test 'syncbind'
wincmd t | set noscrollbind | normal ggL
wincmd j | set noscrollbind | normal ggL
set scrollbind
wincmd t | set scrollbind | normal G
wincmd j | normal G
syncbind
normal Hk
wincmd t | normal H
wincmd j | normal Hyy
wincmd b | normal p
wincmd t | normal yy
wincmd b | normal p
wincmd t | set noscrollbind | normal ggL
wincmd j | set noscrollbind
normal ggL
set scrollbind
wincmd t | set scrollbind
wincmd t | normal G
wincmd j | normal G
wincmd t | syncbind | normal Hk
wincmd j | normal H
wincmd t | normal Hyy
wincmd b | normal p
wincmd t | wincmd j | normal yy
wincmd b | normal p
wincmd t | normal H3k
wincmd j | normal H
wincmd t | normal Hyy
wincmd b | normal p
wincmd t | wincmd j | normal yy
wincmd b | normal p
wincmd b
call assert_equal([
\ '',
\ '. line 16 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 16',
\ 'start of window 2',
\ 'start of window 2',
\ '. line 16 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 16',
\ '. line 15 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ 15',
\ '. line 12 ZYXWVUTSRQPONMLKJIHGREDCBA9876543210 12',
\ ], getline(1, '$'))
enew!
new | only!
set scrollbind& scrollopt& scrolloff& wrap& equalalways& splitbelow&
endfunc