Skip to content

Commit 96c9039

Browse files
committed
fix: when on windows, use a proper \r\n line ending to correctly render
status changes. #1863
1 parent d7d98ea commit 96c9039

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lua/neogit/lib/git/index.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ local git = require("neogit.lib.git")
22
local Path = require("plenary.path")
33
local util = require("neogit.lib.util")
44

5+
local LINE_ENDING = (vim.fn.has("win32") == 1 or vim.fn.has("win64") == 1) and "\r\n" or "\n"
6+
57
---@class NeogitGitIndex
68
local M = {}
79

@@ -64,9 +66,9 @@ function M.generate_patch(hunk, opts)
6466

6567
table.insert(diff_content, 1, string.format("+++ b/%s", path))
6668
table.insert(diff_content, 1, string.format("--- a/%s", path))
67-
table.insert(diff_content, "\n")
69+
table.insert(diff_content, LINE_ENDING)
6870

69-
return table.concat(diff_content, "\n")
71+
return table.concat(diff_content, LINE_ENDING)
7072
end
7173

7274
---@param patch string diff generated with M.generate_patch

0 commit comments

Comments
 (0)