rcarriga / nvim-dap-ui

A UI for nvim-dap
MIT License
2.58k stars 94 forks source link

Flatten is outdated for nvim 0.10.x #362

Open lorenzo-frittoli opened 4 months ago

lorenzo-frittoli commented 4 months ago

I am not sure of the specifics, but in util.lua, at line 318, the function M.tbl_flatten(t) is incorrect. I have found the following fix, if anyone needs it:

function M.tbl_flatten(t)
-  return vim.fn.has("nvim-0.10") == 1 and vim.iter(t):flatten(math.huge):totable()
-    or vim.tbl_flatten(t)
+  if t ~= nil then
+    return {}
+  end
+  if vim.fn.has("nvim-0.10") == 1 then
+    return vim.iter(t):flatten(math.huge):totable()
+  end
+  return vim.tbl_flatten(t)
end

upon fixing this, I found out another error: in logging.lua at line 54: if no log file is present, the program will error. This is apparently intended behavior since the file opening operation is wrapped in an assert block. I am not sure why that is the case, but for my purposes, the logger is not too important, so I just chose to remove the assert, thus creating a new log file if none is present.

-local logfile = assert(io.open(logger._filename, "a+"))
+local logfile = io.open(logger._filename, "a+")

Sorry if I didn't quite follow standard procedure (eg: make a pr, reference files properly) but I am still getting the hang of github. Have a nice day!

JoseConseco commented 3 months ago

Thx for the fixes. Also I had logfile is nil error on line 92 - in logging.lua. the fix is just to check if log file exist...: if logfile then logfile:write(table.concat(parts, " "), "\n") logfile:flush() end
I guess something is not working with the logfile..