From 42cbb41ada884b21d7bbd369003b71752260c44e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 14 Apr 2012 16:01:22 -0400 Subject: always run autocorrect code on fuzzy matches, even if there is just 1 --- CmdLine.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'CmdLine.hs') diff --git a/CmdLine.hs b/CmdLine.hs index 5330f40fc..ebaef5369 100644 --- a/CmdLine.hs +++ b/CmdLine.hs @@ -46,19 +46,19 @@ dispatch fuzzyok allargs allcmds commonoptions header getgitrepo = do where err msg = msg ++ "\n\n" ++ usage header allcmds commonoptions cmd = Prelude.head cmds - (cmds, name, args) = findCmd fuzzyok allargs allcmds err + (fuzzy, cmds, name, args) = findCmd fuzzyok allargs allcmds err (flags, params) = getOptCmd args cmd commonoptions err - checkfuzzy = when (length cmds > 1) $ + checkfuzzy = when fuzzy $ inRepo $ Git.AutoCorrect.prepare name cmdname cmds {- Parses command line params far enough to find the Command to run, and - returns the remaining params. - Does fuzzy matching if necessary, which may result in multiple Commands. -} -findCmd :: Bool -> Params -> [Command] -> (String -> String) -> ([Command], String, Params) +findCmd :: Bool -> Params -> [Command] -> (String -> String) -> (Bool, [Command], String, Params) findCmd fuzzyok argv cmds err | isNothing name = error $ err "missing command" - | not (null exactcmds) = (exactcmds, fromJust name, args) - | fuzzyok && not (null inexactcmds) = (inexactcmds, fromJust name, args) + | not (null exactcmds) = (False, exactcmds, fromJust name, args) + | fuzzyok && not (null inexactcmds) = (True, inexactcmds, fromJust name, args) | otherwise = error $ err $ "unknown command " ++ fromJust name where (name, args) = findname argv [] -- cgit v1.2.3