Hi,

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.

[0]: https://github.com/mhinz/vim-signify/issues/88

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
@@ -34,7 +34,8 @@
 		test81.out test82.out test83.out test84.out test88.out \
 		test89.out test90.out test91.out test92.out test93.out \
 		test94.out test95.out test96.out test97.out test98.out \
-		test99.out test100.out test101.out test102.out test103.out
+		test99.out test100.out test101.out test102.out test103.out \
+		test104.out
 
 .SUFFIXES: .in .out
 
@@ -154,3 +155,4 @@
 test101.out: test101.in
 test102.out: test102.in
 test103.out: test103.in
+test104.out: test104.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
@@ -33,7 +33,7 @@
 		test84.out test85.out test86.out test87.out test88.out \
 		test89.out test90.out test91.out test92.out test93.out \
 		test94.out test95.out test96.out test98.out test99.out \
-		test100.out test101.out test102.out test103.out
+		test100.out test101.out test102.out test103.out test104.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
@@ -53,7 +53,7 @@
 		test84.out test85.out test86.out test87.out test88.out \
 		test89.out test90.out test91.out test92.out test93.out \
 		test94.out test95.out test96.out test98.out test99.out \
-		test100out test101.out test102.out test103.out
+		test100out test101.out test102.out test103.out test104.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
@@ -35,7 +35,7 @@
 		test81.out test82.out test83.out test84.out test88.out \
 		test89.out test90.out test91.out test92.out test93.out \
 		test94.out test95.out test96.out test98.out test99.out \
-		test100.out test101.out test102.out test103.out
+		test100.out test101.out test102.out test103.out test104.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
@@ -79,7 +79,7 @@
 	 test82.out test83.out test84.out test88.out test89.out \
 	 test90.out test91.out test92.out test93.out test94.out \
 	 test95.out test96.out test97.out test98.out test99.out \
-	 test100.out test101.out test102.out test103.out
+	 test100.out test101.out test102.out test103.out test104.out
 
 # Known problems:
 # Test 30: a problem around mac format - unknown reason
diff --git a/src/testdir/Makefile b/src/testdir/Makefile
--- a/src/testdir/Makefile
+++ b/src/testdir/Makefile
@@ -30,7 +30,8 @@
 		test84.out test85.out test86.out test87.out test88.out \
 		test89.out test90.out test91.out test92.out test93.out \
 		test94.out test95.out test96.out test97.out test98.out \
-		test99.out test100.out test101.out test102.out test103.out
+		test99.out test100.out test101.out test102.out test103.out \
+		test104.out
 
 SCRIPTS_GUI = test16.out
 
diff --git a/src/testdir/test104.in b/src/testdir/test104.in
new file mode 100644
--- /dev/null
+++ b/src/testdir/test104.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/test104.ok b/src/testdir/test104.ok
new file mode 100644
--- /dev/null
+++ b/src/testdir/test104.ok
@@ -0,0 +1,2 @@
+
+2
diff --git a/src/window.c b/src/window.c
--- a/src/window.c
+++ b/src/window.c
@@ -4368,20 +4368,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
 }
 
 /*
@@ -4393,12 +4392,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;
 
@@ -4416,13 +4413,8 @@
 		break;
 	    }
 	}
-
+# endif
     return wp;
-# else
-    if (curwin->w_buffer == buf)
-	return curwin;
-    return NULL;
-# endif
 }
 #endif
 

Attachment: signature.asc
Description: Digital signature

Raspunde prin e-mail lui