aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorSteven Arcangeli <stevearc@stevearc.com>2023-08-25 12:02:59 -0700
committerSteven Arcangeli <stevearc@stevearc.com>2023-08-25 12:02:59 -0700
commit08b54ba11e29e6df9f83c02539976331617a412c (patch)
treeb5fe63897e48a414627638bc5c6c5c2721d1f26a /lua
parenta22781e0c3b609a5f90095f388589744567476c7 (diff)
fix: don't modify files when no styling changes
Diffstat (limited to 'lua')
-rw-r--r--lua/conform/runner.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/lua/conform/runner.lua b/lua/conform/runner.lua
index fd806ce..7f11d99 100644
--- a/lua/conform/runner.lua
+++ b/lua/conform/runner.lua
@@ -37,6 +37,11 @@ local function apply_format(bufnr, original_lines, new_lines)
local restore = util.save_win_positions(bufnr)
local original_text = table.concat(original_lines, "\n")
+ -- Trim off the final newline because the original lines won't have it
+ -- and we want the diffs to agree if the file is unchanged
+ if new_lines[#new_lines] == "" then
+ new_lines[#new_lines] = nil
+ end
local new_text = table.concat(new_lines, "\n")
local indices = vim.diff(original_text, new_text, {
result_type = "indices",