diff --git a/src/Lean/Server/InfoUtils.lean b/src/Lean/Server/InfoUtils.lean index b0ccf380df..7acd75f2c8 100644 --- a/src/Lean/Server/InfoUtils.lean +++ b/src/Lean/Server/InfoUtils.lean @@ -257,7 +257,8 @@ partial def InfoTree.goalsAt? (text : FileMap) (t : InfoTree) (hoverPos : String let trailSize := i.stx.getTrailingSize -- show info at EOF even if strictly outside token + trail let atEOF := tailPos.byteIdx + trailSize == text.source.endPos.byteIdx - if pos ≤ hoverPos ∧ (hoverPos.byteIdx <= tailPos.byteIdx + trailSize || atEOF) then + -- include at least one trailing character (see also `priority` below) + if pos ≤ hoverPos ∧ (hoverPos.byteIdx < tailPos.byteIdx + max 1 trailSize || atEOF) then -- overwrite bottom-up results according to "innermost" heuristics documented above if gs.isEmpty || hoverPos ≥ tailPos && gs.all (·.indented) then return [{ diff --git a/tests/lean/interactive/plainGoal.lean b/tests/lean/interactive/plainGoal.lean index c640c7bcee..dfecf2fc93 100644 --- a/tests/lean/interactive/plainGoal.lean +++ b/tests/lean/interactive/plainGoal.lean @@ -85,6 +85,9 @@ example (as bs cs : List α) : (as ++ bs) ++ cs = as ++ (bs ++ cs) := by example : True := (by exact True.intro) --^ $/lean/plainGoal +example : True := (by exact True.intro ) + --^ $/lean/plainGoal + example : False := by -- EOF test --^ $/lean/plainGoal diff --git a/tests/lean/interactive/plainGoal.lean.expected.out b/tests/lean/interactive/plainGoal.lean.expected.out index 2cc0b4a7a5..23f9e13032 100644 --- a/tests/lean/interactive/plainGoal.lean.expected.out +++ b/tests/lean/interactive/plainGoal.lean.expected.out @@ -111,5 +111,8 @@ "position": {"line": 84, "character": 38}} {"rendered": "no goals", "goals": []} {"textDocument": {"uri": "file://plainGoal.lean"}, - "position": {"line": 88, "character": 2}} + "position": {"line": 87, "character": 39}} +null +{"textDocument": {"uri": "file://plainGoal.lean"}, + "position": {"line": 91, "character": 2}} {"rendered": "```lean\n⊢ False\n```", "goals": ["⊢ False"]}