File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -48,15 +48,17 @@ local function upconvert_lsp_goal_to_lean4(response)
48
48
local goals = {}
49
49
for _ , contents in ipairs (response .contents ) do
50
50
if contents .language == ' lean' and contents .value ~= ' no goals' then
51
- -- strip 'N goals' from the front (which is present for multiple goals)
52
- local rest_of_goals = contents .value :gsub (' ^%d+ goals?\n ' , ' ' )
51
+ if contents .value :match (' ⊢' ) then
52
+ -- strip 'N goals' from the front (which is present for multiple goals)
53
+ local rest_of_goals = contents .value :gsub (' ^%d+ goals?\n ' , ' ' )
53
54
54
- repeat
55
- local end_of_goal = _GOAL_MARKER :match_str (rest_of_goals )
56
- table.insert (goals , vim .trim (rest_of_goals :sub (1 , end_of_goal )))
57
- if not end_of_goal then break end
58
- rest_of_goals = rest_of_goals :sub (end_of_goal + 1 )
59
- until rest_of_goals == " "
55
+ repeat
56
+ local end_of_goal = _GOAL_MARKER :match_str (rest_of_goals )
57
+ table.insert (goals , vim .trim (rest_of_goals :sub (1 , end_of_goal )))
58
+ if not end_of_goal then break end
59
+ rest_of_goals = rest_of_goals :sub (end_of_goal + 1 )
60
+ until rest_of_goals == " "
61
+ end
60
62
end
61
63
end
62
64
return { goals = goals }
Original file line number Diff line number Diff line change @@ -54,6 +54,14 @@ describe('infoview', function()
54
54
local text = infoview_lsp_update ({7 , 10 })
55
55
assert .has_all (text , {" p q : Prop" , " h : p ∨ q" , " ⊢ q ∨ p" })
56
56
end )
57
+
58
+ it (' only counts goals as goals, not hovered terms' ,
59
+ function (_ )
60
+ -- hover for Lean 3 will also return information about `nat`, which is
61
+ -- under the cursor, but we shouldn't count that as a goal.
62
+ local text = infoview_lsp_update ({3 , 14 })
63
+ assert .equal (text , ' ▶ 1 goal\n\n ⊢ Type 1' )
64
+ end )
57
65
end )
58
66
59
67
it (' lean 4' , function ()
You can’t perform that action at this time.
0 commit comments