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

Highlighting the current frame does not work #303

Closed
przepompownia opened this issue Nov 11, 2023 · 12 comments · Fixed by #322
Closed

Highlighting the current frame does not work #303

przepompownia opened this issue Nov 11, 2023 · 12 comments · Fixed by #322

Comments

@przepompownia
Copy link
Contributor

image

Currently I can't see which frame is current.

I found DapUICurrentFrameName highlight inside frames.lua but it doesn't seem to be applied. :Inspect on the current frame's line shows

image

@przepompownia
Copy link
Contributor Author

local is_current = frame.id == current_frame_id

I noticed that for PHP adapter for none of frames frame.id == current_frame_id.

Please look into the example from https://github.com/przepompownia/nvim-dap-ui-current-frame-bug (make start should be enough).
image

I'm not sure if the bug lies on nvim-dap-ui side.

@przepompownia
Copy link
Contributor Author

I see that .frames from nvim-dap displays the current frame correctly
image
but after jumping to another frame using default o keymap on the stacks window the current frame is not displayed also there
image
Moreover, jumping between frames by require('dap').up() also returns then an error:
image

@przepompownia
Copy link
Contributor Author

przepompownia commented Nov 27, 2023

I noticed that using frames directly from dap.session

diff --git a/lua/dapui/components/frames.lua b/lua/dapui/components/frames.lua
index 7d1c87c..afbd653 100644
--- a/lua/dapui/components/frames.lua
+++ b/lua/dapui/components/frames.lua
@@ -19,6 +19,7 @@ return function(client, send_ready)
         return
       end
       local frames = response.stackFrames
+      frames = require'dap'.session().threads[thread_id].frames
 
       if not show_subtle then
         frames = vim.tbl_filter(function(frame)

simply works in this example
image
and does not break .frames output and jumping between frames.

przepompownia added a commit to przepompownia/nvim-dap-ui that referenced this issue Nov 27, 2023
Fixes rcarriga#303

It's rather a workaround than an ultimate solution, but shows
that rcarriga#303 can be fixed on dap-ui side.
rcarriga added a commit that referenced this issue Jan 20, 2024
See #303
Closes #307

Co-authored-by: przepompownia <przepompownia@users.noreply.github.com>
@rcarriga
Copy link
Owner

Thanks for the fix, I added a few extra changes and pushed to master

@przepompownia
Copy link
Contributor Author

przepompownia commented Jan 20, 2024

Thank you too. I took a look at how you made the access to frames without direct requireing dap.session in lua/dapui/components/frames.lua. It works for me so we can close this issue.

@przepompownia
Copy link
Contributor Author

...althoug I get

   Warn  06:24:06 PM notify.warn nvim-dap-ui Rendering failed: ...k/bundle/opt/nvim-dap-ui/lua/dapui/components/frames.lua:21: attempt to index a nil value
stack traceback:
	...nfig/nvim/pack/bundle/opt/nvim-dap-ui/lua/dapui/util.lua:26: in function '__index'
	...k/bundle/opt/nvim-dap-ui/lua/dapui/components/frames.lua:21: in function 'render'
	.../bundle/opt/nvim-dap-ui/lua/dapui/components/threads.lua:45: in function 'render_thread'
	.../bundle/opt/nvim-dap-ui/lua/dapui/components/threads.lua:73: in function 'render'
	...ack/bundle/opt/nvim-dap-ui/lua/dapui/elements/stacks.lua:27: in function 'render'
	...ack/bundle/opt/nvim-dap-ui/lua/dapui/elements/stacks.lua:19: in function <...ack/bundle/opt/nvim-dap-ui/lua/dapui/elements/stacks.lua:18>
	[C]: in function 'xpcall'
	...nfig/nvim/pack/bundle/opt/nvim-dap-ui/lua/dapui/util.lua:25: in function <...nfig/nvim/pack/bundle/opt/nvim-dap-ui/lua/dapui/util.lua:21>

after exiting if continue does not meet any breakpoint.

@przepompownia przepompownia reopened this Jan 20, 2024
@mikehaertl
Copy link

Commit a62e86b related to this issue introduced a new error for me. See #321

@przepompownia
Copy link
Contributor Author

Currently in my local env I have

diff --git a/lua/dapui/components/frames.lua b/lua/dapui/components/frames.lua
index f15323b..bc42310 100644
--- a/lua/dapui/components/frames.lua
+++ b/lua/dapui/components/frames.lua
@@ -18,6 +18,18 @@ return function(client, send_ready)

       local current_frame_id = nil

+      local threads = client.session.threads
+
+      if not threads then
+        vim.notify('No threads for session', vim.log.levels.ERROR, {title = 'DAP UI'})
+        return
+      end
+
+      if not threads[thread_id] then
+        vim.notify('No thread ' .. thread_id, vim.log.levels.ERROR, {title = 'DAP UI'})
+        return
+      end
+
       local frames = client.session.threads[thread_id].frames
       if not frames then
         return

to debug what part of path is nil (and avoid this error in a regular work).

@mikehaertl
Copy link

No thread 1
No thread 7

@przepompownia
Copy link
Contributor Author

@mikehaertl thanks for pointing out the place. Do you have a working frames view after this change?

@mikehaertl
Copy link

TBH I'm not sure what frames are. I see threads, though. Here's what a session looks like (Java):

image

@przepompownia
Copy link
Contributor Author

@mikehaertl you have visible frames on the screenshot. The widget hierarchy is DAP Stacks -> threads -> frames (@rcarriga please correct me if I'm wrong).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants