Skip to content

Commit f8e6ab1

Browse files
pepeiborracocreature
authored andcommitted
Fix #247 (#292)
1 parent 821c7f6 commit f8e6ab1

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/Development/IDE/Spans/AtPoint.hs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,16 @@ spansAtPoint :: Position -> [SpanInfo] -> [SpanInfo]
142142
spansAtPoint pos = filter atp where
143143
line = _line pos
144144
cha = _character pos
145-
atp SpanInfo{..} = spaninfoStartLine <= line
146-
&& spaninfoEndLine >= line
147-
&& spaninfoStartCol <= cha
148-
-- The end col points to the column after the
149-
-- last character so we use > instead of >=
150-
&& spaninfoEndCol > cha
145+
atp SpanInfo{..} =
146+
startsBeforePosition && endsAfterPosition
147+
where
148+
startLineCmp = compare spaninfoStartLine line
149+
endLineCmp = compare spaninfoEndLine line
150+
151+
startsBeforePosition = startLineCmp == LT || (startLineCmp == EQ && spaninfoStartCol <= cha)
152+
-- The end col points to the column after the
153+
-- last character so we use > instead of >=
154+
endsAfterPosition = endLineCmp == GT || (endLineCmp == EQ && spaninfoEndCol > cha)
151155

152156
showName :: Outputable a => a -> T.Text
153157
showName = T.pack . prettyprint

test/exe/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ findDefinitionAndHoverTests = let
954954
, test broken broken fffL8 fff "field in record construction #71"
955955
, test yes yes fffL14 fff "field name used as accessor" -- 120 in Calculate.hs
956956
, test yes yes aaaL14 aaa "top-level name" -- 120
957-
, test broken broken dcL7 tcDC "data constructor record #247"
957+
, test yes yes dcL7 tcDC "data constructor record #247"
958958
, test yes yes dcL12 tcDC "data constructor plain" -- 121
959959
, test yes yes tcL6 tcData "type constructor #248" -- 147
960960
, test broken yes xtcL5 xtc "type constructor external #248,249"

0 commit comments

Comments
 (0)