From 5a5216ffb900a9ca63d4436d79a8e7efe9ffca73 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Wed, 8 May 2013 15:44:11 +0200 Subject: [PATCH] Changed method to limit the number of History entries loaded The previous code limited the number of entries that were read into the history array, but the user is expecting a maximum on the number of entries displayed. This can make a little difference in two cases: - if there are duplicate entries (dups are checked for and removed) - if some entries are not strings (unlikely, but not impossible) The new code just stops adding history entries when the user specified count is reached. --- src/dialog.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dialog.c b/src/dialog.c index a3e7e7e6..05087474 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -199,14 +199,15 @@ static WMArray *LoadHistory(const char *filename, int max) if (plhistory && WMIsPLArray(plhistory)) { num = WMGetPropListItemCount(plhistory); - if (num > max) - num = max; for (i = 0; i < num; ++i) { plitem = WMGetFromPLArray(plhistory, i); if (WMIsPLString(plitem) && WMFindInArray(history, strmatch, - WMGetFromPLString(plitem)) == WANotFound) + WMGetFromPLString(plitem)) == WANotFound) { WMAddToArray(history, WMGetFromPLString(plitem)); + if (--max <= 0) + break; + } } } -- 2.11.4.GIT