mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-12-16 11:22:33 +03:00
REPL tab completion now works on all words, not just the first one
This addresses issue #99.
This commit is contained in:
parent
981235118b
commit
8095862a68
@ -16,7 +16,7 @@ import REPL.Monad
|
||||
import REPL.Trie
|
||||
|
||||
import Control.Monad (when)
|
||||
import Data.Char (isSpace)
|
||||
import Data.Char (isAlphaNum, isSpace)
|
||||
import Data.Function (on)
|
||||
import Data.List (isPrefixOf,sortBy)
|
||||
import System.Console.Haskeline
|
||||
@ -147,7 +147,7 @@ cmdArgument ct cursor@(l,_) = case ct of
|
||||
completeExpr :: CompletionFunc REPL
|
||||
completeExpr (l,_) = do
|
||||
ns <- getExprNames
|
||||
let n = reverse l
|
||||
let n = reverse (takeWhile isIdentChar l)
|
||||
vars = filter (n `isPrefixOf`) ns
|
||||
return (l,map (nameComp n) vars)
|
||||
|
||||
@ -155,7 +155,7 @@ completeExpr (l,_) = do
|
||||
completeType :: CompletionFunc REPL
|
||||
completeType (l,_) = do
|
||||
ns <- getTypeNames
|
||||
let n = reverse l
|
||||
let n = reverse (takeWhile isIdentChar l)
|
||||
vars = filter (n `isPrefixOf`) ns
|
||||
return (l,map (nameComp n) vars)
|
||||
|
||||
@ -167,6 +167,8 @@ nameComp prefix c = Completion
|
||||
, isFinished = True
|
||||
}
|
||||
|
||||
isIdentChar :: Char -> Bool
|
||||
isIdentChar c = isAlphaNum c || c `elem` "_\'"
|
||||
|
||||
-- | Join two completion functions together, merging and sorting their results.
|
||||
(+++) :: CompletionFunc REPL -> CompletionFunc REPL -> CompletionFunc REPL
|
||||
|
Loading…
Reference in New Issue
Block a user