diff --git a/README.md b/README.md index 62a6c77..9a06403 100644 --- a/README.md +++ b/README.md @@ -55,10 +55,11 @@ require("nvim-dap-virtual-text").setup { --- @param options nvim_dap_virtual_text_options Current options for nvim-dap-virtual-text --- @return string|nil A text how the virtual text should be displayed or nil, if this variable shouldn't be displayed display_callback = function(variable, buf, stackframe, node, options) + -- by default, strip out new line characters if options.virt_text_pos == 'inline' then - return ' = ' .. variable.value + return ' = ' .. variable.value:gsub("%s+", " ") else - return variable.name .. ' = ' .. variable.value + return variable.name .. ' = ' .. variable.value:gsub("%s+", " ") end end, -- position of virtual text, see `:h nvim_buf_set_extmark()`, default tries to inline the virtual text. Use 'eol' to set to end of line diff --git a/lua/nvim-dap-virtual-text.lua b/lua/nvim-dap-virtual-text.lua index 5c787e7..8c83992 100755 --- a/lua/nvim-dap-virtual-text.lua +++ b/lua/nvim-dap-virtual-text.lua @@ -83,10 +83,11 @@ local options = { --- @return string|nil text how the virtual text should be displayed or nil, if this variable shouldn't be displayed --- @diagnostic disable-next-line: unused-local display_callback = function(variable, buf, stackframe, node, options) + -- by default, strip out new line characters if options.virt_text_pos == 'inline' then - return ' = ' .. variable.value + return ' = ' .. variable.value:gsub('%s+', ' ') else - return variable.name .. ' = ' .. variable.value + return variable.name .. ' = ' .. variable.value:gsub('%s+', ' ') end end, }