Skip to content

Commit caab833

Browse files
authored
Don't show the redundant space (#2788)
* Don't show the redundant space * Fix tests
1 parent 30d48ed commit caab833

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

ghcide/src/Development/IDE/Plugin/Completions/Logic.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ mkNameCompItem doc thingParent origName provenance thingType isInfix docs !imp =
230230
insertText = case isInfix of
231231
Nothing -> case getArgText <$> thingType of
232232
Nothing -> label
233-
Just argText -> label <> " " <> argText
233+
Just argText -> if T.null argText then label else label <> " " <> argText
234234
Just LeftSide -> label <> "`"
235235

236236
Just Surrounded -> label

ghcide/test/exe/Main.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -4057,8 +4057,8 @@ findDefinitionAndHoverTests = let
40574057
, testGroup "hover" $ mapMaybe snd tests
40584058
, checkFileCompiles sourceFilePath $
40594059
expectDiagnostics
4060-
[ ( "GotoHover.hs", [(DsError, (62, 7), "Found hole: _")])
4061-
, ( "GotoHover.hs", [(DsError, (65, 8), "Found hole: _")])
4060+
[ ( "GotoHover.hs", [(DsError, (62, 7), "Found hole: _")])
4061+
, ( "GotoHover.hs", [(DsError, (65, 8), "Found hole: _")])
40624062
]
40634063
, testGroup "type-definition" typeDefinitionTests ]
40644064

@@ -4717,13 +4717,13 @@ nonLocalCompletionTests =
47174717
"constructor"
47184718
["{-# OPTIONS_GHC -Wall #-}", "module A where", "f = True"]
47194719
(Position 2 8)
4720-
[ ("True", CiConstructor, "True ", True, True, Nothing)
4720+
[ ("True", CiConstructor, "True", True, True, Nothing)
47214721
],
47224722
completionTest
47234723
"type"
47244724
["{-# OPTIONS_GHC -Wall #-}", "module A () where", "f :: Boo", "f = True"]
47254725
(Position 2 8)
4726-
[ ("Bool", CiStruct, "Bool ", True, True, Nothing)
4726+
[ ("Bool", CiStruct, "Bool", True, True, Nothing)
47274727
],
47284728
completionTest
47294729
"qualified"
@@ -4898,7 +4898,7 @@ otherCompletionTests = [
48984898
-- This should be sufficient to detect that we are in a
48994899
-- type context and only show the completion to the type.
49004900
(Position 3 11)
4901-
[("Integer", CiStruct, "Integer ", True, True, Nothing)],
4901+
[("Integer", CiStruct, "Integer", True, True, Nothing)],
49024902

49034903
testSession "duplicate record fields" $ do
49044904
void $

test/functional/Completion.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ snippetTests = testGroup "snippets" [
163163
item <- getCompletionByLabel "Nothing" compls
164164
liftIO $ do
165165
item ^. insertTextFormat @?= Just Snippet
166-
item ^. insertText @?= Just "Nothing "
166+
item ^. insertText @?= Just "Nothing"
167167

168168
, testCase "work for polymorphic types" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do
169169
doc <- openDoc "Completion.hs" "haskell"

0 commit comments

Comments
 (0)