Skip to content

Commit 550fbd7

Browse files
alexnaspojneiramergify[bot]alexnaspoleap
authored
case sensitive language pragmas fix (#2142)
Co-authored-by: Javier Neira <atreyu.bbb@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: alexnaspoleap <88672779+alexnaspoleap@users.noreply.github.com>
1 parent bd3a366 commit 550fbd7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ completion _ide _ complParams = do
163163
result <$> VFS.getCompletionPrefix position cnts
164164
where
165165
result (Just pfix)
166-
| "{-# LANGUAGE" `T.isPrefixOf` VFS.fullLine pfix
166+
| "{-# language" `T.isPrefixOf` T.toLower (VFS.fullLine pfix)
167167
= J.List $ map buildCompletion
168168
(Fuzzy.simpleFilter (VFS.prefixText pfix) allPragmas)
169169
| "{-# options_ghc" `T.isPrefixOf` T.toLower (VFS.fullLine pfix)

plugins/hls-pragmas-plugin/test/Main.hs

+12
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,18 @@ completionTests =
258258
item ^. L.label @?= "OverloadedStrings"
259259
item ^. L.kind @?= Just CiKeyword
260260

261+
262+
, testCase "completes language extensions case insensitive" $ runSessionWithServer pragmasPlugin testDataDir $ do
263+
doc <- openDoc "Completion.hs" "haskell"
264+
_ <- waitForDiagnostics
265+
let te = TextEdit (Range (Position 0 4) (Position 0 34)) "lAnGuaGe Overloaded"
266+
_ <- applyEdit doc te
267+
compls <- getCompletions doc (Position 0 24)
268+
let item = head $ filter ((== "OverloadedStrings") . (^. L.label)) compls
269+
liftIO $ do
270+
item ^. L.label @?= "OverloadedStrings"
271+
item ^. L.kind @?= Just CiKeyword
272+
261273
, testCase "completes the Strict language extension" $ runSessionWithServer pragmasPlugin testDataDir $ do
262274
doc <- openDoc "Completion.hs" "haskell"
263275
_ <- waitForDiagnostics

0 commit comments

Comments
 (0)