This repository was archived by the owner on Oct 7, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
src/Haskell/Ide/Engine/Plugin Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -422,13 +422,19 @@ getCompletions uri prefixInfo (WithSnippets withSnippets) =
422422 filtPragmaCompls = filtListWithSnippet mkPragmaCompl validPragmas
423423 filtOptsCompls = filtListWith mkExtCompl
424424
425+ stripLeading :: Char -> String -> String
426+ stripLeading _ [] = []
427+ stripLeading c (s: ss)
428+ | s == c = ss
429+ | otherwise = s: ss
430+
425431 result
426432 | " import " `T.isPrefixOf` fullLine
427433 = filtImportCompls
428434 | " {-# language" `T.isPrefixOf` T. toLower fullLine
429435 = filtOptsCompls cachedExtensions
430436 | " {-# options_ghc" `T.isPrefixOf` T. toLower fullLine
431- = filtOptsCompls (map T. pack $ GHC. flagsForCompletion False )
437+ = filtOptsCompls (map ( T. pack . stripLeading ' - ' ) $ GHC. flagsForCompletion False )
432438 | " {-# " `T.isPrefixOf` fullLine
433439 = filtPragmaCompls (pragmaSuffix fullLine)
434440 | otherwise
Original file line number Diff line number Diff line change @@ -115,6 +115,28 @@ spec = describe "completions" $ do
115115 item ^. insertTextFormat `shouldBe` Just Snippet
116116 item ^. insertText `shouldBe` Just (" OPTIONS_GHC -${1:option} #-}" )
117117
118+ -- -----------------------------------
119+
120+ it " completes ghc options pragma values" $ runSession hieCommand fullCaps " test/testdata/completion" $ do
121+ doc <- openDoc " Completion.hs" " haskell"
122+
123+ _ <- skipManyTill loggingNotification (count 2 noDiagnostics)
124+
125+ let te = TextEdit (Range (Position 0 0 ) (Position 0 0 )) " {-# OPTIONS_GHC -Wno-red #-}\n "
126+ _ <- applyEdit doc te
127+
128+ compls <- getCompletions doc (Position 0 24 )
129+ -- liftIO $ putStrLn $ "completions=" ++ show (map (^.label) compls)
130+ let item = head $ filter ((== " Wno-redundant-constraints" ) . (^. label)) compls
131+ liftIO $ putStrLn $ " item=" ++ show item
132+ liftIO $ do
133+ item ^. label `shouldBe` " Wno-redundant-constraints"
134+ item ^. kind `shouldBe` Just CiKeyword
135+ item ^. insertTextFormat `shouldBe` Nothing
136+ item ^. insertText `shouldBe` Nothing
137+
138+ -- -----------------------------------
139+
118140 it " completes with no prefix" $ runSession hieCommand fullCaps " test/testdata/completion" $ do
119141 doc <- openDoc " Completion.hs" " haskell"
120142 _ <- skipManyTill loggingNotification (count 2 noDiagnostics)
You can’t perform that action at this time.
0 commit comments