From 931cf30e66238432fbf653adda7bd08f05a18e87 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Fri, 3 Oct 2025 21:34:06 +0530 Subject: Add %S substitution for selections as newline separated --- lib/Daffm/Action/Cmdline.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/Daffm') diff --git a/lib/Daffm/Action/Cmdline.hs b/lib/Daffm/Action/Cmdline.hs index 64977aa..e7376c3 100644 --- a/lib/Daffm/Action/Cmdline.hs +++ b/lib/Daffm/Action/Cmdline.hs @@ -63,12 +63,13 @@ cmdSubstitutions cmd = do (AppState {stateFiles, stateCwd, stateFileSelections}) <- get let file = maybe "" (filePath . snd) . L.listSelectedElement $ stateFiles let escape = (\s -> "'" <> s <> "'") . Text.replace "'" "\\'" - let selections = Text.unwords . map (escape . Text.pack) $ Set.elems stateFileSelections + let selections = map Text.pack $ Set.elems stateFileSelections -- TODO: Escaping % let subst = Text.replace "%" (Text.pack file) . Text.replace "%d" (Text.pack stateCwd) - . Text.replace "%s" selections + . Text.replace "%s" (Text.unwords $ map escape selections) + . Text.replace "%S" (Text.dropWhileEnd (== '\n') $ Text.unlines selections) pure . subst $ cmd applyCmdlineEdit :: (Zipper.TextZipper String -> Zipper.TextZipper String) -> AppEvent () -- cgit v1.3.1