Skip to content

Commit 0f15c34

Browse files
committed
Inaccessible names can have characters following the dagger.
1 parent b216e5c commit 0f15c34

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

lua/lean/infoview.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ function Infoview:select_view_options()
729729
},
730730
{
731731
name = 'show inaccessible names',
732-
description = 'Show inaccessible names (those ending in ✝)?',
732+
description = 'Show inaccessible names (those containing ✝)?',
733733
option = 'show_hidden_assumptions',
734734
},
735735
{

lua/lean/widget/interactive_goal.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ local lsp_diagnostics = require('lean.diagnostic').lsp_diagnostics
88
local interactive_goal = {}
99

1010
---A hypothesis name which is accessible according to Lean's naming conventions.
11+
---
12+
---Mirrors `Lean.Name.isInaccessibleUserName`: inaccessible names contain a
13+
---dagger anywhere within them, as shadowed names have further superscript
14+
---indices appended after theirs (e.g. `x✝¹`).
1115
---@param name string
1216
local function is_accessible(name)
13-
return name:sub(-#'') ~= ''
17+
return not name:find('', 1, true)
1418
end
1519

1620
---Render a hypothesis name.

spec/infoview/view_options_spec.lua

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,34 @@ describe('infoview view_options', function()
5151
)
5252
end)
5353

54+
it(
55+
'can hide inaccessible names, even shadowed ones with indices',
56+
helpers.clean_buffer(
57+
[[
58+
example : Nat → Nat → Nat → 37 = 37 := by
59+
intro n n n
60+
sorry
61+
]],
62+
function()
63+
helpers.search 'sorry'
64+
assert.infoview_contents.are [[
65+
n✝¹ n✝ n : Nat
66+
⊢ 37 = 37
67+
]]
68+
69+
local iv = infoview.get_current_infoview()
70+
iv.view_options.show_hidden_assumptions = false
71+
iv.pin:update()
72+
assert.infoview_contents.are [[
73+
n : Nat
74+
⊢ 37 = 37
75+
]]
76+
77+
iv.view_options.show_hidden_assumptions = true
78+
end
79+
)
80+
)
81+
5482
it(
5583
'can be selected interactively via <LocalLeader>v from a Lean buffer',
5684
helpers.clean_buffer(

0 commit comments

Comments
 (0)