From f6137d71c35f265824ac4a5a8c9e1765ca826bb2 Mon Sep 17 00:00:00 2001 From: Mario Mintel <46969863+mintelm@users.noreply.github.com> Date: Thu, 23 Feb 2023 10:02:45 +0100 Subject: [PATCH] fix: check if data is accessible (#241) --- lua/dapui/components/frames.lua | 5 ++++- lua/dapui/components/scopes.lua | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lua/dapui/components/frames.lua b/lua/dapui/components/frames.lua index c636f9b..7d1c87c 100644 --- a/lua/dapui/components/frames.lua +++ b/lua/dapui/components/frames.lua @@ -13,6 +13,7 @@ return function(client, send_ready) ---@param canvas dapui.Canvas render = function(canvas, thread_id, show_subtle, indent) local success, response = pcall(client.request.stackTrace, { threadId = thread_id }) + local current_frame_id = nil if not success then return @@ -25,7 +26,9 @@ return function(client, send_ready) end, frames) end - local current_frame_id = client.session.current_frame and client.session.current_frame.id + if client.session then + current_frame_id = client.session.current_frame and client.session.current_frame.id + end for _, frame in ipairs(frames) do local is_current = frame.id == current_frame_id diff --git a/lua/dapui/components/scopes.lua b/lua/dapui/components/scopes.lua index cd09ca9..48ac4fe 100644 --- a/lua/dapui/components/scopes.lua +++ b/lua/dapui/components/scopes.lua @@ -6,7 +6,9 @@ return function(client, send_ready) ---@type dapui.types.Scope[] | nil local _scopes client.listen.scopes(function(args) - _scopes = args.response.scopes + if args.response then + _scopes = args.response.scopes + end send_ready() end) local on_exit = function()