Skip to content

Commit e5cda9b

Browse files
committed
always save when save_on_fmt enabled
1 parent 03fe793 commit e5cda9b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lua/guard/format.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,19 @@ local function update_buffer(bufnr, prev_lines, new_lines, srow, erow, old_inden
3232
new_lines[#new_lines] = nil
3333
end
3434

35+
local need_write = false
3536
if not vim.deep_equal(new_lines, prev_lines) then
37+
need_write = true
3638
api.nvim_buf_set_lines(bufnr, srow, erow, false, new_lines)
37-
if util.getopt('save_on_fmt') then
38-
api.nvim_command('silent! noautocmd write!')
39-
end
4039
if old_indent then
4140
vim.cmd(('silent %d,%dleft'):format(srow + 1, erow))
4241
end
4342
restore_views(views)
4443
end
44+
45+
if need_write or util.getopt('save_on_fmt') then
46+
api.nvim_command('silent! noautocmd write!')
47+
end
4548
end
4649

4750
local function emit_event(status, data)

0 commit comments

Comments
 (0)