Remove config.use_decoration_api

The decoration provider is now always used.
This commit is contained in:
Lewis Russell 2021-08-05 15:31:54 +01:00
parent 115876cddd
commit 3a477a0356
8 changed files with 58 additions and 88 deletions

View File

@ -526,13 +526,6 @@ use_internal_diff *gitsigns-config-use_internal_diff*
This uses LuaJIT's FFI interface.
use_decoration_api *gitsigns-config-use_decoration_api*
Type: `boolean`, Default: `true`
Use Neovim's decoration API to apply signs. This should improve
performance on large files since signs will only be applied to drawn
lines as opposed to all lines in the buffer.
current_line_blame *gitsigns-config-current_line_blame*
Type: `boolean`, Default: `false`

28
lua/gitsigns.lua generated
View File

@ -418,25 +418,23 @@ M.setup = void(function(cfg)
setup_command()
if config.use_decoration_api then
api.nvim_set_decoration_provider(namespace, {
on_win = function(_, _, bufnr, top, bot)
local bcache = cache[bufnr]
if not bcache or not bcache.pending_signs then
return false
end
manager.apply_win_signs(bufnr, bcache.pending_signs, top + 1, bot + 1)
api.nvim_set_decoration_provider(namespace, {
on_win = function(_, _, bufnr, top, bot)
local bcache = cache[bufnr]
if not bcache or not bcache.pending_signs then
return false
end
manager.apply_win_signs(bufnr, bcache.pending_signs, top + 1, bot + 1)
return config.word_diff and config.use_internal_diff
end,
on_line = function(_, _, bufnr, row)
manager.apply_word_diff(bufnr, row)
end,
})
end
return config.word_diff and config.use_internal_diff
end,
on_line = function(_, _, bufnr, row)
manager.apply_word_diff(bufnr, row)
end,
})
git.enable_yadm = config.yadm.enable
git.set_version(config._git_version)

View File

@ -60,7 +60,6 @@ local M = {Config = {SignsConfig = {}, watch_index = {}, current_line_blame_form
M.config = {}
@ -353,16 +352,6 @@ M.schema = {
]],
},
use_decoration_api = {
type = 'boolean',
default = true,
description = [[
Use Neovim's decoration API to apply signs. This should improve
performance on large files since signs will only be applied to drawn
lines as opposed to all lines in the buffer.
]],
},
current_line_blame = {
type = 'boolean',
default = false,
@ -560,9 +549,18 @@ local function resolve_default(v)
end
end
local function handle_deprecated(cfg)
if cfg.use_decoration_api then
print('Gitsigns: use_decoration_api is now removed; ignoring')
cfg.use_decoration_api = nil
end
end
function M.build(user_config)
user_config = user_config or {}
handle_deprecated(user_config)
validate_config(user_config)
local config = M.config

View File

@ -43,14 +43,9 @@ function M.apply_win_signs(bufnr, pending, top, bot)
local first_apply = top == nil
if config.use_decoration_api then
top = top or vim.fn.line('w0')
bot = bot or vim.fn.line('w$')
else
top = top or 1
bot = bot or vim.fn.line('$')
end
top = top or vim.fn.line('w0')
bot = bot or vim.fn.line('w$')
local scheduled = {}
@ -72,9 +67,7 @@ function M.apply_win_signs(bufnr, pending, top, bot)
if config.use_decoration_api then
schedule_sign(next(pending))
end
schedule_sign(next(pending))
end
signs.add(config, bufnr, scheduled)

View File

@ -418,25 +418,23 @@ M.setup = void(function(cfg: Config)
setup_command()
if config.use_decoration_api then
-- Calling this before any await calls will stop nvim's intro messages being
-- displayed
api.nvim_set_decoration_provider(namespace, {
on_win = function(_, _, bufnr: integer, top: integer, bot: integer): boolean
local bcache = cache[bufnr]
if not bcache or not bcache.pending_signs then
return false
end
manager.apply_win_signs(bufnr, bcache.pending_signs, top+1, bot+1)
-- Returning false prevents the on_line callbacks
return config.word_diff and config.use_internal_diff
end,
on_line = function(_, _, bufnr: integer, row: integer)
manager.apply_word_diff(bufnr, row)
-- Calling this before any await calls will stop nvim's intro messages being
-- displayed
api.nvim_set_decoration_provider(namespace, {
on_win = function(_, _, bufnr: integer, top: integer, bot: integer): boolean
local bcache = cache[bufnr]
if not bcache or not bcache.pending_signs then
return false
end
})
end
manager.apply_win_signs(bufnr, bcache.pending_signs, top+1, bot+1)
-- Returning false prevents the on_line callbacks
return config.word_diff and config.use_internal_diff
end,
on_line = function(_, _, bufnr: integer, row: integer)
manager.apply_word_diff(bufnr, row)
end
})
git.enable_yadm = config.yadm.enable
git.set_version(config._git_version)

View File

@ -46,7 +46,6 @@ local record M
preview_config: {string:any}
attach_to_untracked: boolean
use_internal_diff: boolean
use_decoration_api: boolean
record yadm
enable: boolean
@ -353,16 +352,6 @@ M.schema = {
]]
},
use_decoration_api = {
type = 'boolean',
default = true,
description = [[
Use Neovim's decoration API to apply signs. This should improve
performance on large files since signs will only be applied to drawn
lines as opposed to all lines in the buffer.
]]
},
current_line_blame = {
type = 'boolean',
default = false,
@ -560,9 +549,18 @@ local function resolve_default(v: SchemaElem): any
end
end
local function handle_deprecated(cfg: {string:any})
if cfg.use_decoration_api then
print('Gitsigns: use_decoration_api is now removed; ignoring')
cfg.use_decoration_api = nil
end
end
function M.build(user_config: {string:any})
user_config = user_config or {}
handle_deprecated(user_config)
validate_config(user_config)
local config = M.config as {string:any}

View File

@ -43,14 +43,9 @@ function M.apply_win_signs(bufnr: integer, pending: {integer:Sign}, top: integer
-- clearing all the signs
local first_apply = top == nil
if config.use_decoration_api then
-- Just apply to signs visible in window
top = top or vim.fn.line('w0')
bot = bot or vim.fn.line('w$')
else
top = top or 1
bot = bot or vim.fn.line('$')
end
-- Just apply to signs visible in window
top = top or vim.fn.line('w0')
bot = bot or vim.fn.line('w$')
local scheduled: {integer:Sign} = {}
@ -72,9 +67,7 @@ function M.apply_win_signs(bufnr: integer, pending: {integer:Sign}, top: integer
-- added but none of them are visible in the window, then make sure to add at
-- least one sign. Only do this on the first call after an update when we all
-- the signs have been cleared.
if config.use_decoration_api then
schedule_sign(next(pending))
end
schedule_sign(next(pending))
end
signs.add(config, bufnr, scheduled)

View File

@ -303,11 +303,10 @@ describe('gitsigns', function()
end)
end)
local function testsuite(advanced_features)
local function testsuite(internal_diff)
return function()
before_each(function()
config.use_decoration_api = advanced_features
config.use_internal_diff = advanced_features
config.use_internal_diff = internal_diff
setup_test_repo()
end)
@ -460,11 +459,11 @@ describe('gitsigns', function()
p'run_job: git .* show :0:newfile.txt'
}
if not advanced_features then
if not internal_diff then
table.insert(messages, p'run_job: git .* diff .* /tmp/lua_.* /tmp/lua_.*')
end
local jobs = advanced_features and 8 or 9
local jobs = internal_diff and 8 or 9
table.insert(messages, "update(1): updates: 1, jobs: "..jobs)
match_debug_messages(messages)