Skip to content

Commit a606b75

Browse files
authored
Merge pull request #1427 from NeogitOrg/fix--performance-regression-of-loading-diffs
2 parents 0ecc2e1 + 08f417b commit a606b75

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

lua/neogit/buffers/process/init.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ local config = require("neogit.config")
33
local status_maps = require("neogit.config").get_reversed_status_maps()
44

55
---@class ProcessBuffer
6+
---@field lines integer
7+
---@field truncated boolean
68
---@field buffer Buffer
79
---@field open fun(self)
810
---@field hide fun(self)
@@ -24,6 +26,8 @@ function M:new(process)
2426
content = string.format("> %s\r\n", table.concat(process.cmd, " ")),
2527
process = process,
2628
buffer = nil,
29+
lines = 0,
30+
truncated = false,
2731
}
2832

2933
setmetatable(instance, self)
@@ -67,6 +71,20 @@ function M:refresh()
6771
end
6872

6973
function M:append(data)
74+
self.lines = self.lines + 1
75+
if self.lines > 300 then
76+
if not self.truncated then
77+
self.content = table.concat({ self.content, "\r\n[Output too long - Truncated]" }, "\r\n")
78+
self.truncated = true
79+
80+
if self:is_visible() then
81+
self:refresh()
82+
end
83+
end
84+
85+
return
86+
end
87+
7088
self.content = table.concat({ self.content, data }, "\r\n")
7189

7290
if self:is_visible() then

lua/neogit/process.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,13 @@ function Process:spawn(cb)
249249

250250
local stdout_on_line = function(line)
251251
insert(res.stdout, line)
252-
insert(res.output, line)
253252
self.buffer:append(line)
254253
end
255254

256255
local stderr_on_partial = function() end
257256

258257
local stderr_on_line = function(line)
259258
insert(res.stderr, line)
260-
insert(res.output, line)
261259
self.buffer:append(line)
262260
end
263261

0 commit comments

Comments
 (0)