local internal_open = false local function open_other_file(file) local other = "" if file then if (file:sub(-4) == ".rej") then -- open base file other = file:sub(1, -5) else -- open rejected hunks file other = file .. '.rej' end if vis:file_exists(other) then internal_open = true vis:command('open ' .. other) end end end vis.events.subscribe(vis.events.FILE_OPEN, function (file) if not internal_open then open_other_file(file.path) end end)