X.A.DynamicWorkspaces: Honor searchPredicate in withWorkspace

If the user's prompt configuration has a custom `searchPredicate` (e.g.,
`X.P.FuzzyMatch.fuzzyMatch`) the `withWorkspace` prompt should make use
of it (instead of defaulting to an `isPrefixOf`-style matching).  For
details see

    https://mail.haskell.org/pipermail/xmonad/2021-December/015491.html
This commit is contained in:
ramon diaz-uriarte (at Phelsuma) 2021-12-28 04:29:42 +01:00 committed by slotThe
parent 4d387bbfc9
commit 540635fe1c
2 changed files with 5 additions and 6 deletions

View File

@ -850,6 +850,9 @@
- Fixed a system freeze when using `X.A.CopyWindow.copy` in
combination with `removeWorkspace`.
- `withWorkspace` now honors the users `searchPredicate`, for
example `fuzzyMatch` from `Prompt.FuzzyMatch`.
## 0.16
### Breaking Changes

View File

@ -38,7 +38,7 @@ import XMonad.Prelude (find, isNothing, nub, when)
import XMonad hiding (workspaces)
import XMonad.StackSet hiding (filter, modify, delete)
import XMonad.Prompt.Workspace ( Wor(Wor), workspacePrompt )
import XMonad.Prompt ( XPConfig, mkXPrompt )
import XMonad.Prompt ( XPConfig, mkComplFunFromList', mkXPrompt )
import XMonad.Util.WorkspaceCompare ( getSortByIndex )
import qualified Data.Map.Strict as Map
import qualified XMonad.Util.ExtensibleState as XS
@ -107,17 +107,13 @@ withWorkspaceIndex job widx = do
ilookup :: WorkspaceIndex -> X (Maybe WorkspaceTag)
ilookup idx = Map.lookup idx <$> XS.gets workspaceIndexMap
mkCompl :: [String] -> String -> IO [String]
mkCompl l s = return $ filter (\x -> take (length s) x == s) l
withWorkspace :: XPConfig -> (String -> X ()) -> X ()
withWorkspace c job = do ws <- gets (workspaces . windowset)
sort <- getSortByIndex
let ts = map tag $ sort ws
job' t | t `elem` ts = job t
| otherwise = addHiddenWorkspace t >> job t
mkXPrompt (Wor "") c (mkCompl ts) job'
mkXPrompt (Wor "") c (mkComplFunFromList' c ts) job'
renameWorkspace :: XPConfig -> X ()
renameWorkspace conf = workspacePrompt conf renameWorkspaceByName