Create config directory if it's missing (or repl history won't save).

This commit is contained in:
Erik Svedäng 2019-10-16 11:27:21 +02:00
parent fa3d9b76c8
commit bcea722b84
2 changed files with 2 additions and 1 deletions

View File

@ -18,7 +18,7 @@ configPath :: FilePath -> IO FilePath
configPath = xdgPath D.XdgConfig
createDirectoryIfMissing :: Bool -> FilePath -> IO ()
createDirectoryIfMissing b = D.createDirectoryIfMissing b . toNative
createDirectoryIfMissing createParents = D.createDirectoryIfMissing createParents . toNative
doesFileExist :: FilePath -> IO Bool
doesFileExist = D.doesFileExist . toNative

View File

@ -69,6 +69,7 @@ completeKeywordsAnd words _ word = return $ findKeywords word (words ++ keywords
readlineSettings :: Monad m => [String] -> IO (Settings m)
readlineSettings words = do
historyFile <- configPath "history"
createDirectoryIfMissing True (takeDirectory historyFile)
return $ Settings {
complete = completeWordWithPrev Nothing ['(', ')', '[', ']', ' ', '\t', '\n'] (completeKeywordsAnd words),
historyFile = Just historyFile,