aboutsummaryrefslogtreecommitdiffstats
path: root/init.lua
blob: 7d3dad7e97d62acbd9b525a1f37b96bb610c831d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)