Skip to content

Commit 25530cf

Browse files
committed
Don't be indent-confused by from sorry.
1 parent 44cd9c2 commit 25530cf

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

lua/lean/indent.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,11 @@ function M.indentexpr(linenr)
110110
end
111111

112112
local sorry = sorry_at(linenr - 2, #last - 1)
113-
if sorry and not last:find ':=' then
114-
return math.max(0, sorry - shiftwidth - 1)
113+
if sorry then
114+
local before = last:sub(1, sorry)
115+
if not before:find ':=%s*' and not before:find 'from%s*' then
116+
return math.max(0, sorry - shiftwidth - 1)
117+
end
115118
end
116119

117120
local _, last_indent = last:find '^%s*'

spec/indent_spec.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,24 @@ describe('indent', function()
141141
)
142142
)
143143

144+
it(
145+
'is not confused by sorry after from',
146+
helpers.clean_buffer(
147+
[[
148+
example : 37 = 37 := by
149+
suffices h : 73 = 73 from sorry
150+
]],
151+
function()
152+
helpers.feed 'Gorfl'
153+
assert.contents.are [[
154+
example : 37 = 37 := by
155+
suffices h : 73 = 73 from sorry
156+
rfl
157+
]]
158+
end
159+
)
160+
)
161+
144162
it(
145163
'dedents after focused sorry',
146164
helpers.clean_buffer(

0 commit comments

Comments
 (0)