Don't write to history file for history size of 0.
authorDaniel Carl <danielcarl@gmx.de>
Mon, 9 Jun 2014 13:31:53 +0000 (15:31 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Mon, 9 Jun 2014 13:34:44 +0000 (15:34 +0200)
doc/vimb.1
src/history.c
src/util.c

index 83dbc8b..2ba401a 100644 (file)
@@ -778,7 +778,8 @@ Header completely from request.
 .RE
 .TP
 .B history-max-items (int)
-Maximum number of unique items stored in search-, command or URI history.
+Maximum number of unique items stored in search-, command or URI history. If
+history-max-items is set to 0, the history file will not be changed.
 .TP
 .B home-page (string)
 Homepage that vimb opens if started without a URI.
index 149c1c6..147fc46 100644 (file)
@@ -56,6 +56,12 @@ void history_cleanup(void)
 {
     const char *file;
     GList *list;
+
+    /* don't cleanup the history file if history max size is 0 */
+    if (!vb.config.history_max) {
+        return;
+    }
+
     for (HistoryType i = HISTORY_FIRST; i < HISTORY_LAST; i++) {
         file = get_file_by_type(i);
         list = load(file);
@@ -71,7 +77,9 @@ void history_add(HistoryType type, const char *value, const char *additional)
 {
     const char *file;
 
-    if (!vb.state.enable_history) {
+    /* don't write a history entry to the file if history is disabled or
+     * history max size is set to 0 */
+    if (!vb.state.enable_history || !vb.config.history_max) {
         return;
     }
 
index dba1c75..8f54144 100644 (file)
@@ -122,11 +122,17 @@ GList *util_file_to_unique_list(const char *filename, Util_Content_Func func,
     /* yes, the whole file is read and wen possible don not need all the
      * lines, but this is easier to implement compared to reading the file
      * line wise from ent to begining */
-    char *line, **lines = util_get_lines(filename);
+    char *line, **lines;
     void *value;
     int len, num_items = 0;
 
-    len = g_strv_length(lines);
+    /* return empty list if max items is 0 */
+    if (!max_items) {
+        return gl;
+    }
+
+    lines = util_get_lines(filename);
+    len   = g_strv_length(lines);
     if (!len) {
         return gl;
     }