Skip to content

Commit

Permalink
fix: no need to save/restore window view
Browse files Browse the repository at this point in the history
Since we're applying diffs instead of replacing the entire buffer, the
cursor actually stays in a more predictable location if we _don't_ try
to save & restore the window views.
  • Loading branch information
stevearc committed Aug 28, 2023
1 parent b2915ca commit 5bc69d5
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions lua/conform/runner.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ end
---@param original_lines string[]
---@param new_lines string[]
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 from the formatted text because that is baked in to
-- the vim lines representation
Expand Down Expand Up @@ -72,8 +70,6 @@ local function apply_format(bufnr, original_lines, new_lines)
local replacement = util.tbl_slice(new_lines, start_b, start_b + count_b - 1)
vim.api.nvim_buf_set_lines(bufnr, start_a - 1, start_a - 1 + count_a, true, replacement)
end

restore()
end

---@param bufnr integer
Expand Down

0 comments on commit 5bc69d5

Please sign in to comment.