diff options
-rw-r--r-- | init.lua | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -1,3 +1,5 @@ +local internal_open = false + local function file_exists(path) local f = io.open(path) local out = f ~= nil @@ -7,16 +9,26 @@ local function file_exists(path) return out end -local function open_rej_file(file) +local function open_other_file(file) + local other = "" if file then - local rejfile = file .. '.rej' - if file_exists(rejfile) then - vis:command('open ' .. rejfile) + 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) - open_rej_file(file.path) + if not internal_open then + open_other_file(file.path) + end end) |