fix(ci): selene erorrs

This commit is contained in:
Barrett Ruth 2025-09-19 14:01:17 -04:00
parent 526c82cac0
commit fa8c663f5e
3 changed files with 7 additions and 21 deletions

View file

@ -4,7 +4,7 @@
---@class DiffBackend
---@field name string
---@field render fun(expected: string, actual: string, mode: string?): DiffResult
---@field render fun(expected: string, actual: string): DiffResult
local M = {}
@ -12,9 +12,7 @@ local M = {}
---@type DiffBackend
local vim_backend = {
name = 'vim',
render = function(expected, actual, mode)
-- For vim backend, we return the content as-is since diffthis handles highlighting
local expected_lines = vim.split(expected, '\n', { plain = true, trimempty = true })
render = function(_, actual)
local actual_lines = vim.split(actual, '\n', { plain = true, trimempty = true })
return {
@ -28,7 +26,7 @@ local vim_backend = {
---@type DiffBackend
local git_backend = {
name = 'git',
render = function(expected, actual, mode)
render = function(expected, actual)
-- Create temporary files for git diff
local tmp_expected = vim.fn.tempname()
local tmp_actual = vim.fn.tempname()
@ -59,7 +57,6 @@ local git_backend = {
highlights = {},
}
else
local highlight_module = require('cp.highlight')
return {
content = {},
highlights = {},
@ -114,11 +111,10 @@ end
---@param expected string
---@param actual string
---@param backend_name? string
---@param mode? string
---@return DiffResult
function M.render_diff(expected, actual, backend_name, mode)
function M.render_diff(expected, actual, backend_name)
local backend = M.get_best_backend(backend_name)
return backend.render(expected, actual, mode)
return backend.render(expected, actual)
end
return M

View file

@ -14,7 +14,6 @@ local M = {}
---@param text string Raw git diff output line
---@return string cleaned_text, DiffHighlight[]
local function parse_diff_line(text)
local highlights = {}
local cleaned_text = text
local offset = 0
@ -22,12 +21,7 @@ local function parse_diff_line(text)
for removed_text in text:gmatch('%[%-(.-)%-%]') do
local start_pos = text:find('%[%-' .. vim.pesc(removed_text) .. '%-%]', 1, false)
if start_pos then
-- Remove the marker and adjust positions
local marker_len = #'[-%-%]' + #removed_text
cleaned_text = cleaned_text:gsub('%[%-' .. vim.pesc(removed_text) .. '%-%]', '', 1)
-- Since we're removing text, we don't add highlights for removed content in the actual pane
-- This is handled by showing removed content in the expected pane
end
end
@ -52,9 +46,8 @@ local function parse_diff_line(text)
})
-- Remove the marker
local marker_len = #{ '{+' } + #{ '+}' } + #added_text
final_text = final_text:gsub('{%+' .. vim.pesc(added_text) .. '%+}', added_text, 1)
offset = offset + #{ '{+' } + #{ '+}' }
offset = offset + 4 -- Length of {+ and +}
end
end
@ -99,9 +92,7 @@ function M.parse_git_diff(diff_output)
highlight.line = line_num - 1 -- 0-based for extmarks
table.insert(all_highlights, highlight)
end
elseif line:match('^%-') then
-- Removed line - we handle this in the expected pane, skip for actual
elseif not line:match('^\\') then -- Skip "\ No newline" messages
elseif not line:match('^%-') and not line:match('^\\') then -- Skip removed lines and "\ No newline" messages
-- Unchanged line
local parsed_line, line_highlights = parse_diff_line(line)
table.insert(content_lines, parsed_line)

View file

@ -192,7 +192,6 @@ local function toggle_test_panel(is_debug)
local actual_buf = vim.api.nvim_create_buf(false, true)
-- Set buffer options
local buffer_opts = { 'bufhidden', 'wipe' }
for _, buf in ipairs({ tab_buf, expected_buf, actual_buf }) do
vim.api.nvim_set_option_value('bufhidden', 'wipe', { buf = buf })
vim.api.nvim_set_option_value('readonly', true, { buf = buf })