blob: a32f7531f81e05ab16378c31057673c0de08ece2 (
plain) (
tree)
|
|
local internal_open = false
local function file_exists(path)
local f = io.open(path)
local out = f ~= nil
if out then
io.close(f)
end
return out
end
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 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)
|