diff options
| author | bjorn <bjorn@bringert.net> | 2008-10-28 12:28:46 +0000 |
|---|---|---|
| committer | bjorn <bjorn@bringert.net> | 2008-10-28 12:28:46 +0000 |
| commit | 50b2b453f3028ba5547f6bc7b25e03d1f5f10e0b (patch) | |
| tree | 6abac1a1fb2194bfbe228f6af8b64cfeeee8a82b /src | |
| parent | f8331e5b4baca2372950f34190ff40d1aa495481 (diff) | |
Changed PGF.complete to include the given input if it can be parsed as a complete tree.
Diffstat (limited to 'src')
| -rw-r--r-- | src/PGF.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/PGF.hs b/src/PGF.hs index 754bcf34f..38031dcbd 100644 --- a/src/PGF.hs +++ b/src/PGF.hs @@ -197,7 +197,7 @@ startCat :: PGF -> Type -- to be the empty string. This means that the completions -- will be all possible next words. complete :: PGF -> Language -> Type -> String - -> [String] -- ^ Possible word completions of, + -> [String] -- ^ Possible completions, -- including the given input. @@ -275,11 +275,12 @@ complete pgf from typ input = state0 = initState pgf from typ in case foldM Incremental.nextState state0 ws of Nothing -> [] - Just state -> let compls = Incremental.getCompletions state prefix - in [unwords (ws++[c]) ++ " " | c <- Map.keys compls] + Just state -> + (if null prefix && not (null (extractExps state typ)) then [unwords ws ++ " "] else []) + ++ [unwords (ws++[c]) ++ " " | c <- Map.keys (Incremental.getCompletions state prefix)] where tokensAndPrefix :: String -> ([String],String) - tokensAndPrefix s | not (null s) && isSpace (last s) = (words s, "") + tokensAndPrefix s | not (null s) && isSpace (last s) = (ws, "") | null ws = ([],"") | otherwise = (init ws, last ws) where ws = words s |
