On Fri, Nov 22, 2013 at 12:10:23AM -0500, James McCoy wrote: > As noticed in [0], if a buffer is visible in multiple windows (including > the current window), “:sign jump …” will jump to the first window the > buffer is visible in. The expected behavior would be for the current > window to be used. > > The attached patch fixes this and adds some tests.
Refreshed patch against current sources and renamed the test files to test_signs.*. Cheers, -- James GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy <[email protected]>
diff --git a/src/testdir/Make_amiga.mak b/src/testdir/Make_amiga.mak
--- a/src/testdir/Make_amiga.mak
+++ b/src/testdir/Make_amiga.mak
@@ -45,6 +45,7 @@
test_listlbr_utf8.out \
test_options.out \
test_qf_title.out \
+ test_signs.out \
test_utf8.out
.SUFFIXES: .in .out
@@ -178,4 +179,5 @@
test_listlbr_utf8.out: test_listlbr_utf8.in
test_options.out: test_options.in
test_qf_title.out: test_qf_title.in
+test_signs.out: test_signs.in
test_utf8.out: test_utf8.in
diff --git a/src/testdir/Make_dos.mak b/src/testdir/Make_dos.mak
--- a/src/testdir/Make_dos.mak
+++ b/src/testdir/Make_dos.mak
@@ -44,6 +44,7 @@
test_listlbr_utf8.out \
test_options.out \
test_qf_title.out \
+ test_signs.out \
test_utf8.out
SCRIPTS32 = test50.out test70.out
diff --git a/src/testdir/Make_ming.mak b/src/testdir/Make_ming.mak
--- a/src/testdir/Make_ming.mak
+++ b/src/testdir/Make_ming.mak
@@ -64,6 +64,7 @@
test_listlbr_utf8.out \
test_options.out \
test_qf_title.out \
+ test_signs.out \
test_utf8.out
SCRIPTS32 = test50.out test70.out
diff --git a/src/testdir/Make_os2.mak b/src/testdir/Make_os2.mak
--- a/src/testdir/Make_os2.mak
+++ b/src/testdir/Make_os2.mak
@@ -46,6 +46,7 @@
test_listlbr_utf8.out \
test_options.out \
test_qf_title.out \
+ test_signs.out \
test_utf8.out
.SUFFIXES: .in .out
diff --git a/src/testdir/Make_vms.mms b/src/testdir/Make_vms.mms
--- a/src/testdir/Make_vms.mms
+++ b/src/testdir/Make_vms.mms
@@ -105,6 +105,7 @@
test_listlbr_utf8.out \
test_options.out \
test_qf_title.out \
+ test_signs.out \
test_utf8.out
# Known problems:
diff --git a/src/testdir/Makefile b/src/testdir/Makefile
--- a/src/testdir/Makefile
+++ b/src/testdir/Makefile
@@ -42,6 +42,7 @@
test_listlbr_utf8.out \
test_options.out \
test_qf_title.out \
+ test_signs.out \
test_utf8.out
SCRIPTS_GUI = test16.out
diff --git a/src/testdir/test_signs.in b/src/testdir/test_signs.in
new file mode 100644
--- /dev/null
+++ b/src/testdir/test_signs.in
@@ -0,0 +1,22 @@
+Tests for signs
+STARTTEST
+:so small.vim
+:if !has("signs")
+: e! test.ok
+: wq! test.out
+:endif
+:"
+:sign define JumpSign text=x
+:exe 'sign place 42 line=2 name=JumpSign buffer=' . bufnr('')
+:" Split the window to the bottom to verify :sign-jump will stay in the current
+:" window if the buffer is displayed there
+:bot split
+:exe 'sign jump 42 buffer=' . bufnr('')
+:call append(line('$'), winnr())
+:$-1,$w! test.out
+ENDTEST
+
+STARTTEST
+:qa!
+ENDTEST
+
diff --git a/src/testdir/test_signs.ok b/src/testdir/test_signs.ok
new file mode 100644
--- /dev/null
+++ b/src/testdir/test_signs.ok
@@ -0,0 +1,2 @@
+
+2
diff --git a/src/window.c b/src/window.c
--- a/src/window.c
+++ b/src/window.c
@@ -4406,20 +4406,19 @@
buf_jump_open_win(buf)
buf_T *buf;
{
+ win_T *wp = NULL;
+
+ if (curwin->w_buffer == buf)
+ wp = curwin;
# ifdef FEAT_WINDOWS
- win_T *wp;
-
- for (wp = firstwin; wp != NULL; wp = wp->w_next)
- if (wp->w_buffer == buf)
- break;
+ else
+ for (wp = firstwin; wp != NULL; wp = wp->w_next)
+ if (wp->w_buffer == buf)
+ break;
if (wp != NULL)
win_enter(wp, FALSE);
+# endif
return wp;
-# else
- if (curwin->w_buffer == buf)
- return curwin;
- return NULL;
-# endif
}
/*
@@ -4431,12 +4430,10 @@
buf_jump_open_tab(buf)
buf_T *buf;
{
+ win_T *wp = buf_jump_open_win(buf);
# ifdef FEAT_WINDOWS
- win_T *wp;
tabpage_T *tp;
- /* First try the current tab page. */
- wp = buf_jump_open_win(buf);
if (wp != NULL)
return wp;
@@ -4454,13 +4451,8 @@
break;
}
}
-
+# endif
return wp;
-# else
- if (curwin->w_buffer == buf)
- return curwin;
- return NULL;
-# endif
}
#endif
signature.asc
Description: Digital signature
