Skip to content

Commit 1c04496

Browse files
committed
Properly indent when we're simultaneously focusing and indenting.
(See the test case.)
1 parent 5e3533e commit 1c04496

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

lua/lean/indent.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ function M.indentexpr(linenr)
127127
return last_indent + shiftwidth
128128
end
129129

130-
if INDENT_AFTER:match_str(last) then
131-
return last_indent + shiftwidth
130+
if focuses_at(last, last_indent + 1) then
131+
last_indent = last_indent + #'·'
132132
end
133133

134-
if focuses_at(last, last_indent + 1) then
135-
return last_indent + #'·'
134+
if INDENT_AFTER:match_str(last) then
135+
return last_indent + shiftwidth
136136
end
137137

138138
if not is_declaration_args(linenr - 2) then

spec/indent_spec.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,24 @@ describe('indent', function()
254254
)
255255
)
256256

257+
it(
258+
'indents again after by at focused stuff',
259+
helpers.clean_buffer(
260+
[[
261+
theorem foo : 37 = 37 := by
262+
· have : 37 = 37 := by
263+
]],
264+
function()
265+
helpers.feed 'Gosorry'
266+
assert.contents.are [[
267+
theorem foo : 37 = 37 := by
268+
· have : 37 = 37 := by
269+
sorry
270+
]]
271+
end
272+
)
273+
)
274+
257275
for each in fixtures.indent() do
258276
it(each.description, function()
259277
vim.cmd.edit { each.unindented, bang = true }

0 commit comments

Comments
 (0)