diff --git a/src/nano.h b/src/nano.h
index 468eac708e3cb0c289c8713560abe9ae519879dd..7ef66d551bcee02209412b47283912ef48aba0c9 100644
--- a/src/nano.h
+++ b/src/nano.h
@@ -600,6 +600,9 @@ enum
 /* The maximum number of bytes buffered at one time. */
 #define MAX_BUF_SIZE 128
 
+/* The largest size_t number that doesn't have the high bit set. */
+#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
+
 #ifdef REVISION
 #define BRANDING PACKAGE_VERSION"-git  "REVISION
 #else
diff --git a/src/search.c b/src/search.c
index 407f27ec11597945eb2bffcb1f6ecb0366060de0..ce6bccc5574606ae142102bee2718adda300cac9 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1221,7 +1221,7 @@ void update_history(filestruct **h, const char *s)
     assert(hage != NULL && hbot != NULL);
 
     /* See if this string is already in the history. */
-    thesame = find_history(*hbot, *hage, s, strlen(s));
+    thesame = find_history(*hbot, *hage, s, HIGHEST_POSITIVE);
 
     /* If an identical string was found, delete that item. */
     if (thesame != NULL) {