From 0ff24002e50b0ce6cd75f53293d687a5b5d5c5fd Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Wed, 20 Apr 2016 17:27:47 +0200 Subject: [PATCH] GTK: avoid subsequent duplicate entries in history --- src/HSFM/GUI/Gtk/Utils.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/HSFM/GUI/Gtk/Utils.hs b/src/HSFM/GUI/Gtk/Utils.hs index b976da1..07902ab 100644 --- a/src/HSFM/GUI/Gtk/Utils.hs +++ b/src/HSFM/GUI/Gtk/Utils.hs @@ -152,8 +152,10 @@ rawPathToItem myview tp = do -- |Makes sure the list is max 5. This is probably not very efficient -- but we don't care, since it's a small list anyway. -addHistory :: a -> [a] -> [a] -addHistory i xs +addHistory :: Eq a => a -> [a] -> [a] +addHistory i [] = [i] +addHistory i xs@(x:_) + | i == x = xs | length xs == maxLength = i : take (maxLength - 1) xs | otherwise = i : xs where