Compare commits
2 commits
925ba5cb8a
...
a7d0c04ccf
| Author | SHA1 | Date | |
|---|---|---|---|
| a7d0c04ccf | |||
|
|
a1af48833b |
3 changed files with 47 additions and 5 deletions
|
|
@ -637,10 +637,17 @@ function M.highlight_hunk(bufnr, ns, hunk, opts)
|
|||
|
||||
if opts.highlights.background and is_diff_line then
|
||||
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, buf_line, 0, {
|
||||
line_hl_group = line_hl,
|
||||
number_hl_group = opts.highlights.gutter and number_hl or nil,
|
||||
end_row = buf_line + 1,
|
||||
hl_group = line_hl,
|
||||
hl_eol = true,
|
||||
priority = p.line_bg,
|
||||
})
|
||||
if opts.highlights.gutter then
|
||||
pcall(vim.api.nvim_buf_set_extmark, bufnr, ns, buf_line, 0, {
|
||||
number_hl_group = number_hl,
|
||||
priority = p.line_bg,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
if is_marker and line_len > pw then
|
||||
|
|
|
|||
|
|
@ -347,6 +347,9 @@ end
|
|||
---@param path string
|
||||
---@return string[]?
|
||||
local function read_file_lines(path)
|
||||
if vim.fn.isdirectory(path) == 1 then
|
||||
return nil
|
||||
end
|
||||
local f = io.open(path, 'r')
|
||||
if not f then
|
||||
return nil
|
||||
|
|
@ -540,11 +543,10 @@ local function compute_highlight_groups(is_default)
|
|||
local normal_fg = normal.fg or (dark and 0xcccccc or 0x333333)
|
||||
|
||||
local alpha = config.highlights.blend_alpha or 0.6
|
||||
local text_alpha = math.min(alpha + 0.3, 1.0)
|
||||
local blended_add = blend_color(add_bg, bg, alpha)
|
||||
local blended_del = blend_color(del_bg, bg, alpha)
|
||||
local blended_add_text = blend_color(add_bg, bg, text_alpha)
|
||||
local blended_del_text = blend_color(del_bg, bg, text_alpha)
|
||||
local blended_add_text = add_bg
|
||||
local blended_del_text = del_bg
|
||||
|
||||
local clear_hl = { default = dflt, fg = normal_fg }
|
||||
if not transparent then
|
||||
|
|
|
|||
|
|
@ -165,6 +165,39 @@ describe('context', function()
|
|||
assert.is_nil(hunks[1].context_after)
|
||||
end)
|
||||
|
||||
it('skips when path is a directory', function()
|
||||
vim.fn.mkdir(vim.fs.joinpath(tmpdir, 'subdir'), 'p')
|
||||
|
||||
local hunks = {
|
||||
make_hunk('subdir', {
|
||||
file_new_start = 1,
|
||||
file_new_count = 1,
|
||||
lines = { '+x' },
|
||||
}),
|
||||
}
|
||||
compute_hunk_context(hunks, 25)
|
||||
|
||||
assert.is_nil(hunks[1].context_before)
|
||||
assert.is_nil(hunks[1].context_after)
|
||||
end)
|
||||
|
||||
it('skips when path is a symlink to a directory', function()
|
||||
vim.fn.mkdir(vim.fs.joinpath(tmpdir, 'real_dir'), 'p')
|
||||
vim.uv.fs_symlink(vim.fs.joinpath(tmpdir, 'real_dir'), vim.fs.joinpath(tmpdir, 'link_dir'))
|
||||
|
||||
local hunks = {
|
||||
make_hunk('link_dir', {
|
||||
file_new_start = 1,
|
||||
file_new_count = 1,
|
||||
lines = { '+x' },
|
||||
}),
|
||||
}
|
||||
compute_hunk_context(hunks, 25)
|
||||
|
||||
assert.is_nil(hunks[1].context_before)
|
||||
assert.is_nil(hunks[1].context_after)
|
||||
end)
|
||||
|
||||
it('skips when file does not exist on disk', function()
|
||||
local hunks = {
|
||||
make_hunk('nonexistent.lua', {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue