Skip to content

Commit

Permalink
case sensitive language pragmas fix (#2142)
Browse files Browse the repository at this point in the history
Co-authored-by: Javier Neira <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: alexnaspoleap <[email protected]>
  • Loading branch information
4 people authored Sep 3, 2021
1 parent bd3a366 commit 550fbd7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ completion _ide _ complParams = do
result <$> VFS.getCompletionPrefix position cnts
where
result (Just pfix)
| "{-# LANGUAGE" `T.isPrefixOf` VFS.fullLine pfix
| "{-# language" `T.isPrefixOf` T.toLower (VFS.fullLine pfix)
= J.List $ map buildCompletion
(Fuzzy.simpleFilter (VFS.prefixText pfix) allPragmas)
| "{-# options_ghc" `T.isPrefixOf` T.toLower (VFS.fullLine pfix)
Expand Down
12 changes: 12 additions & 0 deletions plugins/hls-pragmas-plugin/test/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,18 @@ completionTests =
item ^. L.label @?= "OverloadedStrings"
item ^. L.kind @?= Just CiKeyword


, testCase "completes language extensions case insensitive" $ runSessionWithServer pragmasPlugin testDataDir $ do
doc <- openDoc "Completion.hs" "haskell"
_ <- waitForDiagnostics
let te = TextEdit (Range (Position 0 4) (Position 0 34)) "lAnGuaGe Overloaded"
_ <- applyEdit doc te
compls <- getCompletions doc (Position 0 24)
let item = head $ filter ((== "OverloadedStrings") . (^. L.label)) compls
liftIO $ do
item ^. L.label @?= "OverloadedStrings"
item ^. L.kind @?= Just CiKeyword

, testCase "completes the Strict language extension" $ runSessionWithServer pragmasPlugin testDataDir $ do
doc <- openDoc "Completion.hs" "haskell"
_ <- waitForDiagnostics
Expand Down

0 comments on commit 550fbd7

Please sign in to comment.