diff --git a/src/buffer.c b/src/buffer.c
index 94e0b2e0b98e166aedccb0b8dfebbdfea3cf099e..22fa136168855c7167e72eedd5cba8117d4d17aa 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -3134,7 +3134,7 @@ maketitle()
     }
 
     need_maketitle = FALSE;
-    if (!p_title && !p_icon)
+    if (!p_title && !p_icon && lasttitle == NULL && lasticon == NULL)
 	return;
 
     if (p_title)
diff --git a/src/testdir/test47.in b/src/testdir/test47.in
index d8384de785477aefa7b5b9ff737a55d607559627..c87387b2fd5b65b63cf8b32a45a211dbc867f743 100644
--- a/src/testdir/test47.in
+++ b/src/testdir/test47.in
@@ -2,6 +2,8 @@ Tests for vertical splits and filler lines in diff mode
 
 STARTTEST
 :so small.vim
+:" Disable the title to avoid xterm keeping the wrong one.
+:set notitle noicon
 /^1
 yG:new
 pkdd:w! Xtest