Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infer errorformat for terminal buffer from previous buffer #1433

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions lua/dap/session.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,13 @@ end


---@param terminal_win_cmd string|fun(config: dap.Configuration):(integer, integer?)
---@param filetype string
---@param config dap.Configuration
---@return integer bufnr, integer? winnr
local function create_terminal_buf(terminal_win_cmd, filetype, config)
local function create_terminal_buf(terminal_win_cmd, config)
local cur_win = api.nvim_get_current_win()
if type(terminal_win_cmd) == "string" then
api.nvim_command(terminal_win_cmd)
local bufnr = api.nvim_get_current_buf()
if vim.filetype then
local path = vim.filetype.get_option(filetype, "path")
assert(type(path) == "string", "path option must be a string")
vim.bo[bufnr].path = path
end
local win = api.nvim_get_current_win()
api.nvim_set_current_win(cur_win)
return bufnr, win
Expand Down Expand Up @@ -195,7 +189,17 @@ do
end
end
local terminal_win
buf, terminal_win = create_terminal_buf(win_cmd, filetype, config)
local prev_buf = api.nvim_get_current_buf()
buf, terminal_win = create_terminal_buf(win_cmd, config)
assert(buf, "terminal_win_cmd must return a buffer number")
vim.bo[buf].errorformat = vim.bo[prev_buf].errorformat
if vim.filetype then
local path = vim.filetype.get_option(filetype, "path")
assert(type(path) == "string", "path option must be a string")
vim.bo[buf].path = path
else
vim.bo[buf].path = vim.bo[prev_buf].path
end
if terminal_win then
if vim.fn.has('nvim-0.8') == 1 then
-- older versions don't support the `win` key
Expand Down
Loading