aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-05-20 10:42:31 +0200
committerGitHub <noreply@github.com>2019-05-20 10:42:31 +0200
commit60710dee82070834b2bd156738cd1a5379dfc640 (patch)
tree72cf74ab0373fc59b9d09605248bc1d66ceec36c /src
parent8c842b39ba7e88fbe6e2fd562731030d5499e343 (diff)
parent7ea350456d6b2f9c92f3dcf6feb7daa3e0abc079 (diff)
downloadrneovim-60710dee82070834b2bd156738cd1a5379dfc640.tar.gz
rneovim-60710dee82070834b2bd156738cd1a5379dfc640.tar.bz2
rneovim-60710dee82070834b2bd156738cd1a5379dfc640.zip
Merge #10033 from janlazo/vim-8.0.1082
vim-patch:8.0.{1082,1497,1498,1513},8.1.{901,1357,1358}
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c31
-rw-r--r--src/nvim/eval.lua1
-rw-r--r--src/nvim/getchar.c6
-rw-r--r--src/nvim/mark.c80
-rw-r--r--src/nvim/shada.c2
-rw-r--r--src/nvim/testdir/Makefile1
-rw-r--r--src/nvim/testdir/test37.in116
-rw-r--r--src/nvim/testdir/test37.ok33
-rw-r--r--src/nvim/testdir/test_clientserver.vim3
-rw-r--r--src/nvim/testdir/test_jumplist.vim66
-rw-r--r--src/nvim/testdir/test_scrollbind.vim240
11 files changed, 390 insertions, 189 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 132450f7a1..6479163028 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -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
*/
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index a7f8461fc3..d4bb69613e 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -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={},
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index f8c7dc613b..ec14803a2e 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -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;
diff --git a/src/nvim/mark.c b/src/nvim/mark.c
index ecd1f098ca..5c9367ab01 100644
--- a/src/nvim/mark.c
+++ b/src/nvim/mark.c
@@ -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--;
}
}
}
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
index eace4a524c..4440d3905f 100644
--- a/src/nvim/shada.c
+++ b/src/nvim/shada.c
@@ -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;
diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile
index 8ea2689939..7b1f0f59cc 100644
--- a/src/nvim/testdir/Makefile
+++ b/src/nvim/testdir/Makefile
@@ -14,7 +14,6 @@ export NVIM_PRG := $(NVIM_PRG)
export TMPDIR := $(abspath ../../../Xtest-tmpdir)
SCRIPTS_DEFAULT = \
- test37.out \
test42.out \
test48.out \
test52.out \
diff --git a/src/nvim/testdir/test37.in b/src/nvim/testdir/test37.in
deleted file mode 100644
index 156bf74a10..0000000000
--- a/src/nvim/testdir/test37.in
+++ /dev/null
@@ -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)
diff --git a/src/nvim/testdir/test37.ok b/src/nvim/testdir/test37.ok
deleted file mode 100644
index d0b74853b3..0000000000
--- a/src/nvim/testdir/test37.ok
+++ /dev/null
@@ -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
diff --git a/src/nvim/testdir/test_clientserver.vim b/src/nvim/testdir/test_clientserver.vim
index 60ef20e0b2..02840de743 100644
--- a/src/nvim/testdir/test_clientserver.vim
+++ b/src/nvim/testdir/test_clientserver.vim
@@ -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)
diff --git a/src/nvim/testdir/test_jumplist.vim b/src/nvim/testdir/test_jumplist.vim
new file mode 100644
index 0000000000..be1af5e705
--- /dev/null
+++ b/src/nvim/testdir/test_jumplist.vim
@@ -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
diff --git a/src/nvim/testdir/test_scrollbind.vim b/src/nvim/testdir/test_scrollbind.vim
index baa24f1979..6c5488be05 100644
--- a/src/nvim/testdir/test_scrollbind.vim
+++ b/src/nvim/testdir/test_scrollbind.vim
@@ -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