diff --git a/lua/neogit/buffers/process/init.lua b/lua/neogit/buffers/process/init.lua index 6c332a3d5..fa537185d 100644 --- a/lua/neogit/buffers/process/init.lua +++ b/lua/neogit/buffers/process/init.lua @@ -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) @@ -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) @@ -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 diff --git a/lua/neogit/process.lua b/lua/neogit/process.lua index 80c43f516..b8c40a985 100644 --- a/lua/neogit/process.lua +++ b/lua/neogit/process.lua @@ -249,7 +249,6 @@ function Process:spawn(cb) local stdout_on_line = function(line) insert(res.stdout, line) - insert(res.output, line) self.buffer:append(line) end @@ -257,7 +256,6 @@ function Process:spawn(cb) local stderr_on_line = function(line) insert(res.stderr, line) - insert(res.output, line) self.buffer:append(line) end