Skip to content

Commit 26ffeb8

Browse files
committed
Fix quickfix with bashdb
1 parent c94d55e commit 26ffeb8

2 files changed

Lines changed: 14 additions & 31 deletions

File tree

lua/nvimgdb/efmmgr.lua

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,27 @@
22
-- vim: set et ts=2 sw=2:
33

44
---@class EfmMgr errorformat manager
5-
---@field private counters table<string, number> specific errorformat counter
5+
---@field private prev_o_efm string previous 'errorformat' value
66
local efmmgr = {
7-
counters = {}
7+
prev_o_efm = '',
8+
prev_bo_efm = '',
89
}
910

10-
---Destructor
11-
function efmmgr.cleanup()
12-
for f, _ in pairs(efmmgr.counters) do
13-
vim.api.nvim_command("set efm-=" .. f)
14-
end
15-
end
16-
1711
---Add 'efm' for some backend.
1812
---@param formats string[]
1913
function efmmgr.setup(formats)
14+
efmmgr.prev_o_efm = vim.o.efm
15+
efmmgr.prev_bo_efm = vim.bo.efm
16+
vim.o.efm = ''
2017
for _, f in ipairs(formats) do
21-
local c = efmmgr.counters[f]
22-
if c == nil then
23-
c = 0
24-
vim.api.nvim_command("set efm+=" .. f)
25-
end
26-
efmmgr.counters[f] = c + 1
18+
vim.api.nvim_command("set efm+=" .. f)
2719
end
2820
end
2921

3022
---Remove 'efm' entries for some backend.
31-
---@param formats string[]
32-
function efmmgr.teardown(formats)
33-
for _, f in ipairs(formats) do
34-
local c = efmmgr.counters[f] - 1
35-
if c <= 0 then
36-
vim.api.nvim_command("set efm-=" .. f)
37-
efmmgr.counters[f] = nil
38-
else
39-
efmmgr.counters[f] = c
40-
end
41-
end
23+
function efmmgr.teardown()
24+
vim.o.efmmgr = efmmgr.prev_o_efm
25+
vim.bo.efmmgr = efmmgr.prev_bo_efm
4226
end
4327

4428
return efmmgr

lua/nvimgdb/win.lua

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,12 +310,11 @@ function Win:lopen(cmd, mods)
310310
local backend = NvimGdb.here.backend
311311
-- Setup 'errorformat' for the given backend. Do it locally because 'efm' can change be reset when editing files.
312312
efmmgr.setup(backend.get_error_formats())
313-
log.debug({win = self.jump_win, valid = vim.api.nvim_win_is_valid(self.jump_win), llist = llist})
314-
local res = vim.fn.setloclist(0, {}, ' ', {lines = llist})
315-
log.debug({res = res, loclist = vim.fn.getloclist(0, {lines = 1})})
313+
log.debug({llist = llist})
314+
log.debug({efm = backend.get_error_formats()})
315+
vim.fn.setloclist(0, {}, ' ', {lines = llist})
316316
vim.cmd(mods .. ' lopen')
317-
log.debug({win = vim.api.nvim_get_current_win(), loclist = vim.fn.getloclist(vim.api.nvim_get_current_win())})
318-
efmmgr.teardown(backend.get_error_formats())
317+
efmmgr.teardown()
319318
end)
320319
end)
321320
end)

0 commit comments

Comments
 (0)