diff --git a/src/history.c b/src/history.c
index 6297f40bb0928c06e21c861ee24cb67797856f38..ac2f2753cfb3fae1b9e942e41eb50094a8e6b8e2 100644
--- a/src/history.c
+++ b/src/history.c
@@ -257,8 +257,10 @@ bool have_statedir(void)
     if (homedir != NULL) {
 	statedir = concatenate(homedir, "/.nano/");
 
-	if (stat(statedir, &dirstat) == 0 && S_ISDIR(dirstat.st_mode))
+	if (stat(statedir, &dirstat) == 0 && S_ISDIR(dirstat.st_mode)) {
+	    poshistname = concatenate(statedir, POSITION_HISTORY);
 	    return TRUE;
+	}
     }
 
     free(statedir);
@@ -289,9 +291,7 @@ bool have_statedir(void)
 	return FALSE;
     }
 
-    if (ISSET(POS_HISTORY))
-	poshistname = concatenate(statedir, POSITION_HISTORY);
-
+    poshistname = concatenate(statedir, POSITION_HISTORY);
     return TRUE;
 }