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) =
422
422
filtPragmaCompls = filtListWithSnippet mkPragmaCompl validPragmas
423
423
filtOptsCompls = filtListWith mkExtCompl
424
424
425
+ stripLeading :: Char -> String -> String
426
+ stripLeading _ [] = []
427
+ stripLeading c (s: ss)
428
+ | s == c = ss
429
+ | otherwise = s: ss
430
+
425
431
result
426
432
| " import " `T.isPrefixOf` fullLine
427
433
= filtImportCompls
428
434
| " {-# language" `T.isPrefixOf` T. toLower fullLine
429
435
= filtOptsCompls cachedExtensions
430
436
| " {-# options_ghc" `T.isPrefixOf` T. toLower fullLine
431
- = filtOptsCompls (map T. pack $ GHC. flagsForCompletion False )
437
+ = filtOptsCompls (map ( T. pack . stripLeading ' - ' ) $ GHC. flagsForCompletion False )
432
438
| " {-# " `T.isPrefixOf` fullLine
433
439
= filtPragmaCompls (pragmaSuffix fullLine)
434
440
| otherwise
Original file line number Diff line number Diff line change @@ -115,6 +115,28 @@ spec = describe "completions" $ do
115
115
item ^. insertTextFormat `shouldBe` Just Snippet
116
116
item ^. insertText `shouldBe` Just (" OPTIONS_GHC -${1:option} #-}" )
117
117
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
+
118
140
it " completes with no prefix" $ runSession hieCommand fullCaps " test/testdata/completion" $ do
119
141
doc <- openDoc " Completion.hs" " haskell"
120
142
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
You can’t perform that action at this time.
0 commit comments