diff --git a/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs b/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs index c9d0d3aefb..9e91b6348d 100644 --- a/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs +++ b/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs @@ -36,7 +36,7 @@ import Development.IDE (GetParsedModule (GetParsedModule), import Development.IDE.GHC.Compat (GenLocated (L), getSessionDynFlags, hsmodName, importPaths, locA, pattern RealSrcSpan, - pm_parsed_source, unLoc) + pm_parsed_source, unLoc, moduleNameString) import Ide.Types import Language.LSP.Server import Language.LSP.Types hiding @@ -140,7 +140,7 @@ codeModuleName :: IdeState -> NormalizedFilePath -> IO (Maybe (Range, T.Text)) codeModuleName state nfp = runMaybeT $ do pm <- MaybeT . runAction "ModuleName.GetParsedModule" state $ use GetParsedModule nfp L (locA -> (RealSrcSpan l _)) m <- MaybeT . pure . hsmodName . unLoc $ pm_parsed_source pm - pure (realSrcSpanToRange l, T.pack $ show m) + pure (realSrcSpanToRange l, T.pack $ moduleNameString m) -- traceAs :: Show a => String -> a -> a -- traceAs lbl a = trace (lbl ++ " = " ++ show a) a diff --git a/plugins/hls-module-name-plugin/test/Main.hs b/plugins/hls-module-name-plugin/test/Main.hs index b6a35af926..ce0fa1e746 100644 --- a/plugins/hls-module-name-plugin/test/Main.hs +++ b/plugins/hls-module-name-plugin/test/Main.hs @@ -37,6 +37,12 @@ tests = [CodeLens { _command = Just c }] <- getCodeLenses doc executeCommand c void $ skipManyTill anyMessage (message SWorkspaceApplyEdit) + , testCase "Should not show code lens if the module name is correct" $ + runSessionWithServer moduleNamePlugin testDataDir $ do + doc <- openDoc "CorrectName.hs" "haskell" + lenses <- getCodeLenses doc + liftIO $ lenses @?= [] + closeDoc doc ] goldenWithModuleName :: TestName -> FilePath -> (TextDocumentIdentifier -> Session ()) -> TestTree diff --git a/plugins/hls-module-name-plugin/test/testdata/CorrectName.hs b/plugins/hls-module-name-plugin/test/testdata/CorrectName.hs new file mode 100644 index 0000000000..e78f2247a1 --- /dev/null +++ b/plugins/hls-module-name-plugin/test/testdata/CorrectName.hs @@ -0,0 +1 @@ +module CorrectName where diff --git a/plugins/hls-module-name-plugin/test/testdata/hie.yaml b/plugins/hls-module-name-plugin/test/testdata/hie.yaml index d9e8533d22..022fee55a1 100644 --- a/plugins/hls-module-name-plugin/test/testdata/hie.yaml +++ b/plugins/hls-module-name-plugin/test/testdata/hie.yaml @@ -5,3 +5,4 @@ cradle: - "TEmptyModule" - "TWrongModuleName" - "mainlike" + - "CorrectName" diff --git a/test/functional/Progress.hs b/test/functional/Progress.hs index 23f7d35362..e4f84f82ce 100644 --- a/test/functional/Progress.hs +++ b/test/functional/Progress.hs @@ -33,7 +33,7 @@ tests = let path = "diagnostics" "Foo.hs" _ <- openDoc path "haskell" expectProgressMessages [pack ("Setting up testdata (for " ++ path ++ ")"), "Processing", "Indexing"] [] - , knownBrokenForGhcVersions [GHC92] "No evaluation status with GHC 9.2" $ requiresEvalPlugin $ testCase "eval plugin sends progress reports" $ + , requiresEvalPlugin $ testCase "eval plugin sends progress reports" $ runSession hlsCommand progressCaps "plugins/hls-eval-plugin/test/testdata" $ do doc <- openDoc "T1.hs" "haskell" lspId <- sendRequest STextDocumentCodeLens (CodeLensParams Nothing Nothing doc)