From 649a199b70c51aadcfc6ef7bf290142cd9bc8f1b Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Fri, 18 Mar 2022 21:47:02 +0800 Subject: [PATCH 1/2] Don't show the redundant space --- ghcide/src/Development/IDE/Plugin/Completions/Logic.hs | 2 +- test/functional/Completion.hs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs index 845cb12c93..14b8143dbf 100644 --- a/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs +++ b/ghcide/src/Development/IDE/Plugin/Completions/Logic.hs @@ -230,7 +230,7 @@ mkNameCompItem doc thingParent origName provenance thingType isInfix docs !imp = insertText = case isInfix of Nothing -> case getArgText <$> thingType of Nothing -> label - Just argText -> label <> " " <> argText + Just argText -> if T.null argText then label else label <> " " <> argText Just LeftSide -> label <> "`" Just Surrounded -> label diff --git a/test/functional/Completion.hs b/test/functional/Completion.hs index 29b7c173f9..d7635e5558 100644 --- a/test/functional/Completion.hs +++ b/test/functional/Completion.hs @@ -163,7 +163,7 @@ snippetTests = testGroup "snippets" [ item <- getCompletionByLabel "Nothing" compls liftIO $ do item ^. insertTextFormat @?= Just Snippet - item ^. insertText @?= Just "Nothing " + item ^. insertText @?= Just "Nothing" , testCase "work for polymorphic types" $ runSession hlsCommand fullCaps "test/testdata/completion" $ do doc <- openDoc "Completion.hs" "haskell" From 274b1b06a8dc16144c8c12e7be959142879e5ade Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Fri, 18 Mar 2022 22:33:26 +0800 Subject: [PATCH 2/2] Fix tests --- ghcide/test/exe/Main.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index e7b8ab335c..ee8aee6654 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -4057,8 +4057,8 @@ findDefinitionAndHoverTests = let , testGroup "hover" $ mapMaybe snd tests , checkFileCompiles sourceFilePath $ expectDiagnostics - [ ( "GotoHover.hs", [(DsError, (62, 7), "Found hole: _")]) - , ( "GotoHover.hs", [(DsError, (65, 8), "Found hole: _")]) + [ ( "GotoHover.hs", [(DsError, (62, 7), "Found hole: _")]) + , ( "GotoHover.hs", [(DsError, (65, 8), "Found hole: _")]) ] , testGroup "type-definition" typeDefinitionTests ] @@ -4717,13 +4717,13 @@ nonLocalCompletionTests = "constructor" ["{-# OPTIONS_GHC -Wall #-}", "module A where", "f = True"] (Position 2 8) - [ ("True", CiConstructor, "True ", True, True, Nothing) + [ ("True", CiConstructor, "True", True, True, Nothing) ], completionTest "type" ["{-# OPTIONS_GHC -Wall #-}", "module A () where", "f :: Boo", "f = True"] (Position 2 8) - [ ("Bool", CiStruct, "Bool ", True, True, Nothing) + [ ("Bool", CiStruct, "Bool", True, True, Nothing) ], completionTest "qualified" @@ -4898,7 +4898,7 @@ otherCompletionTests = [ -- This should be sufficient to detect that we are in a -- type context and only show the completion to the type. (Position 3 11) - [("Integer", CiStruct, "Integer ", True, True, Nothing)], + [("Integer", CiStruct, "Integer", True, True, Nothing)], testSession "duplicate record fields" $ do void $