summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Senn <rsx@bluewin.ch>2021-02-04 10:43:04 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-13 21:29:30 -0500
commit793dcb3de47587f849ad286caf362cac0c67edb2 (patch)
tree71e626343c1da4d186519c58766b5bf030c7917d
parentf1362008daabb518b6fcd8079fb89683fb642597 (diff)
downloadhaskell-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.
-rw-r--r--ghc/GHCi/UI.hs13
-rw-r--r--testsuite/tests/ghci/scripts/T10576a.stdout2
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T6
3 files changed, 14 insertions, 7 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
diff --git a/testsuite/tests/ghci/scripts/T10576a.stdout b/testsuite/tests/ghci/scripts/T10576a.stdout
index 8949cff3e4..1069c6ac77 100644
--- a/testsuite/tests/ghci/scripts/T10576a.stdout
+++ b/testsuite/tests/ghci/scripts/T10576a.stdout
@@ -1,2 +1,2 @@
1 1 ""
-"\2600\2600" \ No newline at end of file
+"\9728\9728" \ No newline at end of file
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 13b2b73b6c..64f87bc7e2 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -240,10 +240,8 @@ test('T11098', normal, ghci_script, ['T11098.script'])
test('T8316', expect_broken(8316), ghci_script, ['T8316.script'])
test('T11252', normal, ghci_script, ['T11252.script'])
-test('T10576a', [extra_files(['T10576.hs']), expect_broken(10576)],
- ghci_script, ['T10576a.script'])
-test('T10576b', [extra_files(['T10576.hs']), expect_broken(10576)],
- ghci_script, ['T10576b.script'])
+test('T10576a', extra_files(['T10576.hs']), ghci_script, ['T10576a.script'])
+test('T10576b', extra_files(['T10576.hs']), ghci_script, ['T10576b.script'])
test('T11051a', normal, ghci_script, ['T11051a.script'])
test('T11051b', normal, ghci_script, ['T11051b.script'])
test('T11266', ignore_stdout, ghci_script, ['T11266.script'])