Skip to content

Commit 73a26ab

Browse files
authored
fix: indexing function value when sending to REPL (#455)
Fixes #358, fixes #444
1 parent 851f6f0 commit 73a26ab

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lua/dapui/util.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ function M.partial(func, ...)
255255
end
256256

257257
function M.send_to_repl(expression)
258-
local repl_win = vim.fn.bufwinid("\\[dap-repl\\]")
258+
local repl_win = vim.fn.bufwinid("\\[dap-repl") -- incomplete bracket to allow e.g. '[dap-repl-2]'
259259
if repl_win == -1 then
260260
M.float_element("repl")
261261
repl_win = vim.fn.bufwinid("\\[dap-repl\\]")
@@ -269,7 +269,8 @@ function M.float_element(elem_name)
269269
local col_no = vim.fn.screencol()
270270
local position = { line = line_no, col = col_no }
271271
local elem = require("dapui.elements." .. elem_name)
272-
return require("dapui.windows").open_float(elem, position, elem.float_defaults or {})
272+
if type(elem) == "function" then elem = elem() end
273+
return require("dapui.windows").open_float(elem_name, elem, position, elem.settings or {})
273274
end
274275

275276
function M.render_type(maybe_type)

lua/dapui/windows/init.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ function M.open_float(name, element, position, settings)
124124
return float_windows[name]
125125
end
126126
local buf = element.buffer()
127+
if type(settings) == "function" then
128+
settings = settings()
129+
end
127130
local float_win = require("dapui.windows.float").open_float({
128131
height = settings.height or 1,
129132
width = settings.width or 1,

0 commit comments

Comments
 (0)