Skip to content

Commit

Permalink
Add config.max_file_length
Browse files Browse the repository at this point in the history
  • Loading branch information
lewis6991 committed Feb 27, 2021
1 parent b866c83 commit 093da28
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/gitsigns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ status_formatter *gitsigns-config-status_formatter*
<
Function used to format `b:gitsigns_status`.

max_file_length *gitsigns-config-max_file_length*
Type: `number`, Default: `40000`

Max file length to attach to.

debug_mode *gitsigns-config-debug_mode*
Type: `boolean`, Default: `false`

Expand Down
6 changes: 6 additions & 0 deletions lua/gitsigns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,12 @@ local attach = throttle_leading(100, sync(function()
end
dprint('Attaching', cbuf, 'attach')

local lc = api.nvim_buf_line_count(cbuf)
if lc > config.max_file_length then
dprint('Exceeds max_file_length', cbuf, 'attach')
return
end

if api.nvim_buf_get_option(cbuf, 'buftype') ~= '' then
dprint('Non-normal buffer', cbuf, 'attach')
return
Expand Down
8 changes: 8 additions & 0 deletions lua/gitsigns/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ local schema = {
]],
},

max_file_length = {
type = 'number',
default = 40000,
description = [[
Max file length to attach to.
]],
},

debug_mode = {
type = 'boolean',
default = false,
Expand Down
6 changes: 6 additions & 0 deletions teal/gitsigns.tl
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,12 @@ local attach = throttle_leading(100, sync(function()
end
dprint('Attaching', cbuf, 'attach')

local lc = api.nvim_buf_line_count(cbuf)
if lc > config.max_file_length then
dprint('Exceeds max_file_length', cbuf, 'attach')
return
end

if api.nvim_buf_get_option(cbuf, 'buftype') ~= '' then
dprint('Non-normal buffer', cbuf, 'attach')
return
Expand Down
8 changes: 8 additions & 0 deletions teal/gitsigns/config.tl
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ local schema: {string:SchemaElem} = {
]]
},

max_file_length = {
type = 'number',
default = 40000,
description = [[
Max file length to attach to.
]]
},

debug_mode = {
type = 'boolean',
default = false,
Expand Down
1 change: 1 addition & 0 deletions teal/gitsigns/types.tl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ global record Config
record watch_index
interval: number
end
max_file_length: number
status_formatter: function(StatusObj): string
end

Expand Down

0 comments on commit 093da28

Please sign in to comment.