From f670ee5d8ba9da4caddf439525ab307737c2396e Mon Sep 17 00:00:00 2001 From: Alex Naspo Date: Sun, 29 Aug 2021 13:31:33 -0400 Subject: [PATCH] case sensitive language pragmas fix --- plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs | 2 +- plugins/hls-pragmas-plugin/test/Main.hs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs b/plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs index 444722e18d..757bb5764e 100644 --- a/plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs +++ b/plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs @@ -160,7 +160,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) | otherwise diff --git a/plugins/hls-pragmas-plugin/test/Main.hs b/plugins/hls-pragmas-plugin/test/Main.hs index 987586083b..2d4112272b 100644 --- a/plugins/hls-pragmas-plugin/test/Main.hs +++ b/plugins/hls-pragmas-plugin/test/Main.hs @@ -256,6 +256,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