diff options
author | Roland Senn <rsx@bluewin.ch> | 2021-02-04 10:43:04 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-02-13 21:29:30 -0500 |
commit | 793dcb3de47587f849ad286caf362cac0c67edb2 (patch) | |
tree | 71e626343c1da4d186519c58766b5bf030c7917d /ghc | |
parent | f1362008daabb518b6fcd8079fb89683fb642597 (diff) | |
download | haskell-793dcb3de47587f849ad286caf362cac0c67edb2.tar.gz |
GHCi :complete command for operators: Fix spaceless cases of #10576.
When separating operators from identifiers in a `:complete` command
take advantage from the different character sets of the two items:
* operators contain only specialSymbol characters.
* Identifiers don't contain specialSymbol characters, with the exception of dots.
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/GHCi/UI.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index 7dc253b894..97b5f57447 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -3466,9 +3466,18 @@ completeMacro = wrapIdentCompleter $ \w -> do completeIdentifier line@(left, _) = -- Note: `left` is a reversed input case left of - (x:_) | isSymbolChar x -> wrapCompleter (specials ++ spaces) complete line - _ -> wrapIdentCompleter complete line + ('.':_) -> wrapCompleter (specials ++ spaces) complete line + -- operator or qualification + (x:_) | isSymbolChar x -> wrapCompleter (specials ++ spaces) + complete (takeOpChars line) -- operator + _ -> wrapIdentCompleter complete (takeIdentChars line) where + takeOpChars (l, r) = (takeWhile isSymbolChar l, r) -- #10576 + -- An operator contains only symbol characters + takeIdentChars (l, r) = (takeWhile notOpChar l, r) + -- An identifier doesn't contain symbol characters with the + -- exception of a dot + notOpChar c = (not .isSymbol ) c || c == '.' complete w = do rdrs <- GHC.getRdrNamesInScope dflags <- GHC.getSessionDynFlags |