Skip to content

Commit 06b9677

Browse files
committed
Render hover doc
1 parent 44fdcdb commit 06b9677

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

ghcide/src/Development/IDE/Core/Actions.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ getAtPoint file pos = runMaybeT $ do
7777
mergeContent Nothing x@Just{} = x
7878
mergeContent (Just (r1, txt1)) (Just (r2, txt2)) =
7979
if r1 == r2
80-
then Just (r1, txt1 <> txt2)
80+
then Just (r1, txt1 <> filter (not . T.null) txt2)
8181
else Just (r1, txt1)
8282

8383
toCurrentLocations :: PositionMapping -> [Location] -> [Location]

ghcide/src/Development/IDE/Spans/AtPoint.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ fixityAtPoint (HAR _ hf _ _ _) env tcGblEnv pos = fmap listToMaybe $ sequence $
217217
fixityInfo ast = do
218218
let range = realSrcSpanToRange $ nodeSpan ast
219219
names = mapMaybe eitherToMaybe $ M.keys $ getNodeIds ast
220-
getFixity names >>= (\fixities -> pure (Just range, [toHoverContent fixities]))
220+
fixities <- getFixity names
221+
pure (Just range, [toHoverContent fixities])
221222

222223
-- We use `handleGhcException` here to prevent hover crashed.
223224
-- Because `runTcInteractive` may throw an exception if something

ghcide/test/exe/Main.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6550,10 +6550,11 @@ hoverFixityTests = testGroup "Explicit fixity"
65506550
, hoverTest "signature" (Position 35 2) "infixr 9 `>>>:`"
65516551
, hoverTest "operator" (Position 36 2) "infixr 9 `>>>:`"
65526552
, hoverTest "escape" (Position 39 2) "infixl 3 `~\\:`"
6553+
, expectFail $ hoverTest "import" (Position 2 18) "Control.Monad***"
65536554
-- It will cause error like: "Failed to load interface for \8216Fixity\8217\nIt is not a module in the current program, or in any known package."
65546555
-- while we look up fixities from imported local defined module, see test below.
65556556
, expectFailBecause "Not support yet"
6556-
$ hoverTestImport "import" (Position 4 7) "infixr 9 `>>>:`"
6557+
$ hoverTestImport "imported" (Position 4 7) "infixr 9 `>>>:`"
65576558
]
65586559
where
65596560
hoverTest = hoverTest' "Fixity.hs"

0 commit comments

Comments
 (0)