Skip to content

Address performance regression #1427

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lua/neogit/buffers/process/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ local config = require("neogit.config")
local status_maps = require("neogit.config").get_reversed_status_maps()

---@class ProcessBuffer
---@field lines integer
---@field truncated boolean
---@field buffer Buffer
---@field open fun(self)
---@field hide fun(self)
Expand All @@ -24,6 +26,8 @@ function M:new(process)
content = string.format("> %s\r\n", table.concat(process.cmd, " ")),
process = process,
buffer = nil,
lines = 0,
truncated = false,
}

setmetatable(instance, self)
Expand Down Expand Up @@ -67,6 +71,20 @@ function M:refresh()
end

function M:append(data)
self.lines = self.lines + 1
if self.lines > 300 then
if not self.truncated then
self.content = table.concat({ self.content, "\r\n[Output too long - Truncated]" }, "\r\n")
self.truncated = true

if self:is_visible() then
self:refresh()
end
end

return
end

self.content = table.concat({ self.content, data }, "\r\n")

if self:is_visible() then
Expand Down
2 changes: 0 additions & 2 deletions lua/neogit/process.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,13 @@ function Process:spawn(cb)

local stdout_on_line = function(line)
insert(res.stdout, line)
insert(res.output, line)
self.buffer:append(line)
end

local stderr_on_partial = function() end

local stderr_on_line = function(line)
insert(res.stderr, line)
insert(res.output, line)
self.buffer:append(line)
end

Expand Down
Loading