Coder Social home page Coder Social logo

Comments (9)

mfussenegger avatar mfussenegger commented on June 11, 2024 1

Could you try with:

local dap = require("dap")
local session = dap.session()
if session and session.parent then
    dap.set_session(session.parent)
end
dap.terminate()

Doing this implicitly within terminate() could be an option

from nvim-dap.

foxt451 avatar foxt451 commented on June 11, 2024

I've delved a bit more into it and I can actually terminate the debuggee after the first breakpoint with firing 3 terminate commands (and in case of the second breakpoint too). I don't think this is expected... The terminate requests have to occur with some delay in between

Btw, node version doesn't seem to matter

from nvim-dap.

mfussenegger avatar mfussenegger commented on June 11, 2024

vscode-js-debug starts multiple sub-sessions and terminate currently only terminates the active session.
The multi-session feature is unfortunately a bit underspecified in the spec. E.g. debugpy uses it too for python multiprocessing, and there I haven't noticed that it's necessary to terminate multiple times. But I think it might be reasonable to broadcast a terminate to all children of a session.

You can see the sessions using something like:

:lua local w = require("dap.ui.widgets"); w.sidebar(w.sessions, {}, '5 sp').toggle()

from nvim-dap.

foxt451 avatar foxt451 commented on June 11, 2024

Thanks! Do you imagine some clean way of terminating all the children as well?
I tried this:

      {
        "<leader>dt",
        function()
          require("dap").terminate()
          local all_sessions = require("dap").sessions()
          for _, session in ipairs(all_sessions) do
            session:disconnect({
              terminateDebuggee = true
            })
          end
        end,
        desc = "Terminate"
      },

(and without require("dap").terminate() and with the order swapped)
but when I start the previous debug configuration again, it will either not react to dt at all, or disconnect without temrinating debugee, or the terminal is empty, or it doesn't continue after the breakpoint, depending on the order of the statements

from nvim-dap.

maxbol avatar maxbol commented on June 11, 2024

+1 for this experience not being very good, whether or not it is in the scope of nvim-dap to fix it...

from nvim-dap.

maxbol avatar maxbol commented on June 11, 2024

Interestingly, I was experience the same "three strikes" behavior as you did @foxt451 , but if I open up the sessions list as described by @mfussenegger and then selecting the top level session before running terminate(), the debugger and debuggee both immediately terminate. So if there was some way of programatically finding out which the top level session is, switching to it as the active one, and running terminate, that would likely fix the issue.

from nvim-dap.

maxbol avatar maxbol commented on June 11, 2024

The following hackish bind solves the issue for me right now. If someone can tell me how to actually tell it to set the top level session of the branch that I'm currently on, and not just the first best one, that would be awesome!

         {
		"<leader>dt",
		function()
			local dap = require("dap")

			local session_to_activate = nil
			local sessions = dap.sessions()

			for _, s in pairs(sessions) do
				session_to_activate = s
				break
			end

			if session_to_activate ~= nil then
				dap.set_session(session)
			end

			dap.terminate()
		end,
		desc = "Terminate",
	}

from nvim-dap.

maxbol avatar maxbol commented on June 11, 2024

Cool, didn't know about session.parent! Will try.

How about if the focused session is more than one level deep? Maybe a while loop to traverse until session.parent is nil? Not sure if this is a real world case though (but I know that these things go more than one level deep with JS, but it seems to always break at the 1-level deep session)

from nvim-dap.

maxbol avatar maxbol commented on June 11, 2024

Btw, how would you recommend setting a bind to terminate ALL sessions?

from nvim-dap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.