mirror of
https://github.com/xmonad/xmonad.git
synced 2025-08-09 16:41:51 -07:00
fix empty case in 'filter', and note differences in semantics wrt. focus to 'delete'
This commit is contained in:
13
StackSet.hs
13
StackSet.hs
@@ -302,11 +302,16 @@ differentiate (x:xs) = Just $ Stack x [] xs
|
|||||||
-- /O(n)/. 'filter p s' returns the elements of 's' such that 'p' evaluates to
|
-- /O(n)/. 'filter p s' returns the elements of 's' such that 'p' evaluates to
|
||||||
-- True. Order is preserved, and focus moves to the next node to the right (if
|
-- True. Order is preserved, and focus moves to the next node to the right (if
|
||||||
-- necessary).
|
-- necessary).
|
||||||
|
--
|
||||||
|
-- Note, this isn't the same as the 'remove' semantics, as focus
|
||||||
|
-- won't move 'left' on the end of list.
|
||||||
|
--
|
||||||
filter :: (a -> Bool) -> Stack a -> StackOrNot a
|
filter :: (a -> Bool) -> Stack a -> StackOrNot a
|
||||||
filter p (Stack f ls rs) = Just $ case L.filter p (f:rs) of
|
filter p (Stack f ls rs) = case L.filter p (f:rs) of
|
||||||
(f':rs') -> Stack f' (L.filter p ls) rs'
|
f':rs' -> Just $ Stack f' (L.filter p ls) rs' -- maybe move focus down
|
||||||
_ -> Stack f' [] rs'
|
[] -> case L.filter p (reverse ls) of -- filter back up
|
||||||
where (f':rs') = reverse (L.filter p ls)
|
f':rs' -> Just $ Stack f' [] rs' -- else up
|
||||||
|
[] -> Nothing
|
||||||
|
|
||||||
-- |
|
-- |
|
||||||
-- /O(s)/. Extract the stack on the current workspace, as a list.
|
-- /O(s)/. Extract the stack on the current workspace, as a list.
|
||||||
|
Reference in New Issue
Block a user