Did i stash my changes and reapply them to the debugger branch? Maybe, did I then proceed to
freak out for quite a bit and wonder why there were so many conflicts and my changes were messed up?
Perhaps, did I realize my mistake and commit to the right branch? Hopefully
Project is no longer responsible for toggle breakpoints or telling breakpoint store to toggle breakpoints.
Now editor toggles breakpoints by directly telling breakpoint store too. In the future I plan on removing
on breakpoint related handling from project to breakpoint store.
I also fix some debugger related test compile errors. Plenty of them won't pass because we're still in a refactor,
but they build now
* Initial setup for breakpoint store
* WIP Move more methods to breakpoint store
* Move event handler to breakpoint store
* Fix compiler errrors
* Fix more compiler errors
* Get Zed to compile
---------
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Move most of the requests into the client state itself.
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
* WIP
* Fix some errors and create new errors
* More teardown
* Fix detach requests
* Move set variable value to dap command
* Fix dap command error and add evaluate command
* FIx more compiler errors
* Fix more compiler errors
* Clipppyyyy
* FIx more
* One more
* Fix one more
* Use threadId from project instead u64
* Mostly fix stack frame list
* More compile errors
* More
* WIP transfer completions to dap command
Co-Authored-By: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
Co-Authored-By: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
* Finish console completions DapCommand impl
* Get Zed to build !!
* Fix test compile errors: The debugger tests will still fail
* Add threads reqeust to debug session
Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
---------
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
This fixes also an issue that Piotr was having with step debugging Python. Because we now always send the request event though the adapter didn't support it. This is only for the new request structure
This should fix issues when we update a module it's content. That wouldn't show up anymore. So by always resetting the list we should get the most up-to-date value.
NOTE: We probably want to reduce the amount of resets and notifies every time we update the client state, even though we didn't update the modules.
We could send and specific event from the client state, each time we update a module. So instead of using a observer we could use a normal event subscriber and only update the list based on that event
* WIP setup active debug sessions request
* Set up active debug sessions request that's send when joining a project
* Fix test debug panel console
* Remove debugger tables from collab db
* Wip request active debug sessions
* WIP
Co-Authored-By: Piotr Osiewicz <piotr@zed.dev>
Co-Authored-By: Anthony Eid <hello@anthonyeid.me>
* Tear stuff out and make the world burn
Co-authored-by: Remco Smits <djsmits12@gmail.com>
Co-authored-by: Piotr <piotr@zed.dev>
* Fix compile errors
* Remove dap_store from module list and fix some warnings
Module list now uses Entity<DebugSession> to get active modules and handle remote/local state
so dap_store is no longer needed
* Add Cacheable Command trait
This gets rid of ClientRequest or whatever the name was; we don't need to enumerate every possible request and repeat ourselves, instead letting you mark any request as cached with no extra boilerplate.
* Add Eq requirement for RequestSlot
* Implement DapCommand for Arc<DapCommand>
That way we can use a single allocated block for each dap command to store it as both the cache key and the command itself.
* Clone Arc on demand
* Add request helper
* Start work on setting up a new dap_command_handler
* Make clippy pass
* Add loaded sources dap command
* Set up module list test to see if Modules request is called
* Fix compile warnings
* Add basic local module_list test
* Add module list event testing to test_module_list
* Bring back as_any_arc
* Only reset module list's list state when modules_len changes
---------
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Co-authored-by: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Piotr <piotr@zed.dev>
This PR makes adding icons to the primary and secondary actions, in the
`MessageNotification` component, optional. Also took the opportunity to
remove a probably unnecessary "third action" from it; streamlining the
component API (we had added that for a design that we're not using
anymore). I did keep the "more info" possibility, which may be useful in
the future, though.
Release Notes:
- N/A
Follow-up to https://github.com/zed-industries/zed/pull/24278
This PR ensures we're checking if there's a license-type file in both US
& UK English spelling, and fixes the error logging again, treating for
when the worktree contains just a single file or multiple.
Release Notes:
- N/A
Co-authored-by: Bennet Bo Fenner <53836821+bennetbo@users.noreply.github.com>
Go back to a less optimized implementation for now since the custom
cursor target seems to have some bugs.
Release Notes:
- Fixed missing git blame and status output in some projects with
multiple git repositories
Rework of https://github.com/zed-industries/zed/pull/24130
Uses
1033c0b57e
`COMMIT_EDITMSG` language-related definitions (thanks @d1y )
Instead of using real `.git/COMMIT_EDITMSG` file, create a buffer
without FS representation, stored in the `Repository` and shared the
regular way via the `BufferStore`.
Adds a knowledge of what `Git Commit` language is, and uses it in the
buffers which are rendered in the git panel.
Release Notes:
- N/A
---------
Co-authored-by: Conrad Irwin <conrad@zed.dev>
Co-authored-by: d1y <chenhonzhou@gmail.com>
Co-authored-by: Smit <smit@zed.dev>
When you have an edit prediction available, you can now also accept it
with `alt-tab` (or `alt-enter` on Linux) even if you don't have an LSP
completions menu open. This is meant to lower the mental load when going
from one mode to another.
Release Notes:
- N/A
* Reapply "Lazy load stack frame information (scopes & variables) (#106)"
This reverts commit 27b60436b8.
* Reapply "Remove futures from debugger ui crate"
This reverts commit 3cf96588e2.
* Don't fetch initial variables twice
This was introduced by my original PR, because I added the fetch on stack frame select but when the stack frames where updated we would already fetch the initial variables. And when the selectedStackFrameUpdated event was received we would refetch it because it was not done yet.
* Remove duplicated method just for testing
* Make keep open entries work again
The issue was the we used the scope_id, which changes after each debug step. So using the name of the scope instead should be more reliable.
* Correctly invalidate variable list information
* Comment out collab variable list for now
Also commenting out an event that triggers the infinite loop.
We want to revisited the collab stuff anyway so we decided to do it this way.
I'm reverting this because it introduced a regression with collab's test
variable list & didn't supoort fetching stack frames initiated by a
remote user.
This reverts commit 945e3226d8.
This PR shows console output & removes the query bar for remote clients.
We don't show the query bar because it's currently impossible for remote clients to send evaluations requests from their console. We didn't implement that feature yet because of security consoles and will do so in the future with permissions.
Co-authored-by: Remco Smits \<djsmits12@gmail.com\>
* Add basic collab debug console test
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Show output events on remote client debug consoles
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Don't show debug console query bar on remote clients
Co-authored-by: Remco Smits <djsmits12@gmail.com>
---------
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Add tests for incremental fetching scopes & variables for stack frames
* Fetch scopes and variables when you select a stack frame
* Send proto update message when you select a stack frame
The debugger collab tests are difficult to understand and read due to the sheer size of each test and the setup involved to start a collab debugger session. This PR aims to mitigate these problems by creating a struct called Zed Instance that manages setting up tests and joining/rejoining collab debug sessions.
* Create util functions to set up debugger collab tests
* WIP converting debugger collab tests to use ZedInstance
* Clean up collab test utility functions to work with 3 member calls
* Update item set on join project test to use new api
* Update test update breakpoints send to dap
* Update test_ignore_breakpoints
* Update last collab tests
* Don't setup file tree for tests that don't need it
Before this change it was impossible to see the command arguments, as the executable was to long.
This changes that so we use the process name as executable name VSCode as seems to do this. So you could still see the arguments of the program.
I also added a tooltip to see the correct executable + arguments.
* WIP add toolchain for python
Co-Authored-By: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
* Integrate toolchain store with dap_store & use it for debugpy
* Wip require worktree to start debug session
* Move start debug session to project for determing the worktree
* Make all tests pass again
* Make collab tests pass
* Use notify instead of manual notification
* Use reference instead of clone
* Revert "Use reference instead of clone"
This reverts commit 61469bb1679bc35d5d3bf0b93e5b7cfc94357c80.
* Revert "Use notify instead of manual notification"
This reverts commit a0b9bf52a1d948dfb244c4b7040576a34ec6f465.
* Revert debugger branch merge
* Revert "Revert debugger branch merge"
This reverts commit 56c883d4dba4877826ea2185a8177fddefa0d054.
* Clean up
* Make node runtime required
* Pass worktree id into get_environment
* Fix use the resolved debug adapter config
* Add fallback if toolchain could not be found to common binary names
---------
Co-authored-by: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
We checked if the user passed in an lldb-dap path after we searched for lldb-dap in PATH.
I switched around the order so if there's a user_installed_path passed through it takes
priority
* Start adding docs for configurations and adapters
* Update debugger setting files with settings, attach config, & themes
I also ran prettier and typos on it too."
---------
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
* Create collab ignore breakpoint integration test
* Add collab ignore breakpoints message handlers
Still need to enable remote dap_stores the ability to store/manage ignore breakpoint state
* Refactor session to have remote and local modes
This was done to allow remote clients access to some session details they need such as ignore breakpoints.
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* DapStore so both local & remote modes have access to DebugSessions
* Add remote sessions when creating new debug panel items
* Finish implementing collab breakpoints ignore
* Clippy & clean up
* Clean up session information when sessions end on remote clients
* Rename proto message
* Add ignore breakpoints state to collab db
---------
Co-authored-by: Remco Smits <djsmits12@gmail.com>
So before this change, if you have save breakpoints feature enabled. You had to have the buffer open for the breakpoint to be send after you launched Zed again. Because we needed to have a buffer to determine the right position based on a anchor.
This changes that so we fallback the cached position (last known), that we stored in the DB. So it could be that the file has changed on disk without Zed knowning. But it's better then not sending the breakpoints at all
Co-Authored-By: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
* Impl VariablesCommand for dap requests
* Have remote variable list generate entries & other fields locally
* Finish first version of collab variable list test (It fails)
* Get variable list collab test to pass
* Update variable test again (it failing)
* Improve tests more WIP
* Remove a test to make merge easier
* Finalize collab test
* Only send variables one time to collab server instead of each rebuild
* Finish variable list fetch!
* Resend breakpoints when the source/edit has been changed/saved
* Check for dapstore first before checking project path
* Add test to validate we re-send variables when editor is saved
* Add new line after edit
* Also send breakpoints changed when source on disk changed
* Fix the test
* Don't send breakpoints changed for saved event
We send the breakpoints twice, because we already send them when the FileHandleChanged event was received and that is received after the Saved event itself. And the Saved event does not guarantee that the source is already changed on disk. Which it has to be so we can send the new breakpoints.
* Assert in more places that the source modified is false
This PR fixes a module list bug where remote clients wouldn't have any modules in their module list when they hit their first breakpoint.
We now send module list changes whenever there is a module list update and don't send update messages in the SetDebuggerPanelItem proto message. This is because the module list usually doesn't change each time a user steps over, so sending the module list was wasting bandwidth.
* Add collab module list test
* Get module list to send during all changes & stop redundant update
* Update module list test for remote clients joining mid session
So this changes the behavior for providing variables for autocompletion inside the debug console if the adapter does not support autocompletion.
Before this change you would get variables based on the selected stack frame. But this is not correct, as you cannot use variables that are not in scope anymore. So changing it to only provide variables for the current(first) stack frame we should provide variables that could always be used for autocompletion and for expressions.
* Remove output editor
* Implement output grouping
* Remove OutputGroup when we found the end position
* Fix make gutter smaller
* Render placeholder
* Show group end on the same level as group start
* Add tests
* Add support for collapsed grouped output
* Fix crease placeholder is not showing up
* Don't trim output multiple times
* Update tests
* Fix clippy
* WIP Start work to send all dap client requests with request_dap
* Continue work on converting dap client requests
* WIP setup dap command for proto dap requests
* WIP dap command
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* revert "WIP dap command"
This reverts commit fd2a6832b667aa23caf588c3ab55243319bc1654.
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* More WIP with Dap Command trait
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Get step over command to work with remote dap clients
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Fix thread status not being set to stop on remote debug panel items
* Create a inner wrapper type to use for dap remote step requests
* Implement step in,back,out for remote debugger sessions
* Add Continue Command
* Add more dap command impls
TerminateThreads, Pause, and Disconnect. As well as a shutdown session request downstream clients can send to host
* Add Disconnect & Terminate dap command impls
* Add basic dap proxy test over collab
* Fix clippy error
* Start work on syncing breakpoint thread status
Co-authored-by: Remco Smits <djsmits12@gmail.com>
Co-authored-by: Carter Canedy <cartercanedy42@gmail.com>
* WIP Fix thread status not syncing
* Add thread state model's to remote debug panels when setting panel items
* Sync thread state on step out command
---------
Co-authored-by: Remco Smits <djsmits12@gmail.com>
Co-authored-by: Carter Canedy <cartercanedy42@gmail.com>
* Switch debug session exited without hitting breakpoint to toast notification
* Move notify below the thread event, so we register the thread is added
---------
Co-authored-by: Remco Smits <djsmits12@gmail.com>
I updated the tests so we don't reuse the debug panel item for each operation, instead we request a new instance each time so we can ensure the status actually changed.
* WIP
* Add assert helper for variable list visual entries
* Wip rework toggle entry (scope/variable) code
* Remove commented code
* Move colors to struct
* Add entry to selection if you click on them
* Add selected option to visual entries assert
* Use pretty assertions for visual entries assert helper
* Use focus handle method to give focus handle
* Register select first and last actions
* Correctly format selected entry
* Add tests helper to get active debug panel item
* Add tests for keyboard navigation
* Remove not needed comment
* Move other tests to test helper
This also removes a test that is duplicated with the keyboard navigation tests, it covers the same
* Update console test to use new test helper
* Fix failing test
I forgot to update the test, because we now always send a body back in a error case.
* Fix clippyyyy
When thread status is not Stopped users are unable to click buttons. So the thread status
needs to be reset if any of the above requests fail or else a user loses to ability to
click any of the debug buttons related to those requests
Before this commit downstream clients in active debug sessions relied
on the host to send them the active debug line. This had three main
limitations (Which are solved by this commit)
1. Downstream clients didn't have the ability to click on their own stack
frame list and go to that frame's location
2. Downstream clients would always follow the host when checking out stack
frames even from a different debug adapter or thread
3. If a user joins an active debug session they wouldn't have an active
debug line until the host's debug adapter sent another stop event
This PR integrates Zed's Debugger with the Collab database, enabling Zed to guarantee that clients joining a project with active debug sessions in progress will receive and set up those sessions.
* Add test for setting active debug panel items on project join
* Add DebuggerSession proto message
* Modify debugger session
* Get collab server to build
* Get collab test to compile
* Add proto messages
* Set up message handler for get debugger sessions
* Send set debug panel requests when handling get debugger sessions msg
* Get request to send and set debug panel
* Setup ground work for debug sessions collab db table
* Set up debug_client table for collab db
* Remove up GetDebuggerSession proto request code
* Get proto::DebuggerSession during join_project_internal
* Remove debug_sessions table from collab db
* Add migration for debug_client and fix some bugs
* Create dap store event queue for remote daps
When creating a project in from_join_project_response(...) the debug panel hasn't been initialized yet so
it can't handle dap_store events. The solution to this is creating an event queue that debug panel takes
from dap store if it's remote and then handles all the events
* Fix debug panel join project during session test
* Add debug_panel_items table to collab db
* Integrate debug_panel_item table into collab msg handlers
* Finialize debug_panel_item table refactor for collab db
* Integrate UpdateDebugAdapter RPC with collab DB
* Handle ShutdownDebugClient RPC for collab db
* Fix clippy
Right now when you add `"cwd": "$ZED_WORKTREE_ROOT/some/path"` to your config,
it won't work as expected. Because we only added the `cwd` to the task template when the cwd was a valid path.
But when you add `"cwd": "$ZED_WORKTREE_ROOT` to your config, it will never be a valid path, so the `cwd` will never be added to the task template and fallback to the `$ZED_WORKTREE_ROOT` already.
So by just always adding it to the task template, we will try to resolve it and otherwise fallback to the `$ZED_WORKTREE_ROOT`.
This occurs when you start a JavaScript debug session, that tells Zed to spawn a debug terminal, without having a breakpoint for the session. The debug adapter terminates the terminal but also terminates Zed because we send the Zed process ID to the debug adapter to keep track of the terminal as extra information, because we already send the pid of the spawned terminal.
So removing the process_id of Zed itself fixes the crash😀
You can reproduce this by using the following config:
```json
{
"label": "JavaScript debug terminal",
"adapter": "javascript",
"request": "launch",
"cwd": "$ZED_WORKTREE_ROOT",
// "program": "$ZED_FILE", // this is optional, but will also crash
"initialize_args": {
"console": "integratedTerminal"
}
}
```
After fn on_response() was created we added a test feature that allowed us to
return error responses. We serialized responses wrapped around
a Result type, causing serde_json::from_value(R::Response) to fail when
attempting to get a response and returning a default response instead.
I also fixed two bugs. Where not adding a log message to a standard breakpoint
would remove it (That shouldn't happen) and the breakpoint prompt editor not
always returning focus to the editor
The bug was caused by removing the breakpoint_set associated to a project_paths
when removing the last breakpoint in the set and there were active debug sessions.
Causing Zed to never tell active DAPs that the last breakpoint was removed.
We now only remove breakpoint_set if there's no active sessions. A better solution
would be removing breakpoint_set after sending all breakpoint requests to active DAPs.
Also, we only send initial breakpoint requests for project paths that contain breakpoints now.
This change replaces the Vec-based implementation with SumTree,
significantly improving performance for frequent insertions. While
the impact may not be immediately noticeable to users, it eliminates the need for costly vector shifts during each insert operation.
* WIP introduce debug session model
* Wip more refactor towards session model
* Fix some compile errors
* Move sub menu item into own struct
* Don't show client id inside selected value
* Remove unused session_id from shutdown event
* Remove clients from dap store use from sessions instead
* Fix clippy
* Add client id to received event log
* Move reconnect client work again
* Move sessions to local dap store
* Move ingore breakpoints to session model
* Move next session/client id to local store
* Remove duplicated test support only method
* Show client id first in dap log menu entry
* Show sub menu better
* Sort clients by their id
* Sort sessions by their id
* Fix configuration done race condition with sending breakpoints
@Anthony-Eid I think this fixed the race condition you noticed with the configuration done request.
So the issue is when the task is created it directly start the execution of the task itself.
So the `configuration_done` request is most of the times finished before the breakpoints are send
if you don't have a lot of breakpoints.
So instead of creating both tasks before the task is created we now create the 2 tasks right after eachother,
so we can be sure that the `configuration_done` request is send after the breakpoints are send.
```
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 received event `Initialized`
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 send `setBreakpoints` request with sequence_id: 3
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 send `setBreakpoints` request with sequence_id: 4
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 send `configurationDone` request with sequence_id: 8
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 send `setBreakpoints` request with sequence_id: 9
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 send `setBreakpoints` request with sequence_id: 7
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 send `setBreakpoints` request with sequence_id: 5
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 received response for: `setBreakpoints` sequence_id: 3
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 received response for: `setBreakpoints` sequence_id: 4
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 send `setBreakpoints` request with sequence_id: 6
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 received response for: `configurationDone` sequence_id: 8
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 received response for: `setBreakpoints` sequence_id: 9
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 received response for: `setBreakpoints` sequence_id: 7
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 received response for: `setBreakpoints` sequence_id: 5
[2024-12-25T21:51:09+01:00 DEBUG dap::client] Client 0 received response for: `setBreakpoints` sequence_id: 6
```
```
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 received event `Initialized`
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 send `setBreakpoints` request with sequence_id: 4
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 send `setBreakpoints` request with sequence_id: 5
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 send `setBreakpoints` request with sequence_id: 6
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 send `setBreakpoints` request with sequence_id: 7
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 send `setBreakpoints` request with sequence_id: 8
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 send `setBreakpoints` request with sequence_id: 3
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 received response for: `setBreakpoints` sequence_id: 4
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 received response for: `setBreakpoints` sequence_id: 5
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 received response for: `setBreakpoints` sequence_id: 6
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 received response for: `setBreakpoints` sequence_id: 7
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 received response for: `setBreakpoints` sequence_id: 8
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 received response for: `setBreakpoints` sequence_id: 3
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 send `configurationDone` request with sequence_id: 9
[2024-12-25T21:49:51+01:00 DEBUG dap::client] Client 0 received response for: `configurationDone` sequence_id: 9
```
* Move capabilities back to dapstore itself
* Fix failing remote debug panel test
* Remove capabilities on remote when client shutdown
* Move client_by_session to local store and impl multi client shutdown
* Remove unused code
* Fix clippyyy
* Rename merge capabilities method
As we don't only merge we also insert if there is no capabilities for the client yet.
* Use resolved label for debug session name
* Notify errors when start client to user
* Notify reconnect error to user
* Always shutdown all clients
We should always shutdown all clients from a single debug session when one is shutdown/terminated.
* Start work on getting dap clients to sync capabilities
* Add notify when syncing capabilities
* Remove client capabilities in handle shutdown debug client
* Add step back support for DAP
The step back button is hidden because most dap implementations don't support
it.
* Add step back as global action - Thanks Remco for the advice!
* Filter step back action when not avaliable
We don't have followableItem impl for debug_panel_item yet
so this test will always fail. I commented out some lines and
put a todo that we'll get to after standard collab works for the
debugger
* Initial WIP for impl FollowableItem for DebugPanelItem
* Implment DebuggerThreadState proto functions
* Add Debug panel item variable list definition to zed.proto
* Add more debug panel item messages to zed.proto
* WIP
* Fix compile errors
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* More WIP
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Further WIP lol
* Start working on fake adapter WIP
Co-authored-by: Remco Smits <djsmits12@gmail.com>
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
* Merge with Remco's mock debug adapter client branch
* Fix false positive clippy error
This error was a match variant not being covered when the variant wasn't possible dued
to a feature flag. I'm pretty sure this is a bug in clippy/rust-analyzer and will
open an issue on their repos
* Add todo to change in dap adapter downloads
* WIP Get variable to send during variable list
* Get variable list from/to_proto working
Note: For some reason variable entries aren't rendering even though
everything is being sent
* Fix warning messages
* Fix typo
* Impl stack from list from/to_proto for debug panel item
* Change order of set_from_proto for debug panel item
* Impl Variable list variables to/from proto funcs
* Start work on Set Debugger Panel Item event
* WIP with remco
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Get SetDebugPanelItem proto message sending and handled
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Setup UpdateDebugAdapter collab message & send live stack frame list updates
* Use proto enums instead of hardcoded integers
* Use read instead of update
* Send variable list update message each time we build the entries
* Send stack frame message when we selected the active stackframe
* Add more mappings
* Remove debug and rename method to be more inline with others
* Use the correct entries to reset
* Add tests to validate we can go and from proto ScopeVariableIndex
* Rename test
* Create UpdateAdapter ModuleList variant WIP
* Change proto conversion trait to have some types return Result enums
* Get clippy to pass
I removed some proto message we used in DebugPanelItem FollowableItem implmentation
because they were causing clippy errors and will need to be change in the near
future anyway
---------
Co-authored-by: Remco Smits <djsmits12@gmail.com>
Co-authored-by: Mikayla Maki <mikayla@zed.dev>
* Add debug panel flow tests
* Wip debug
* Wip fix test
Co-Authored-By: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
* WIP Get test_show_debug_panel to run
while the test now runs without panicing dued to parked with nothing left to run
the debug panel item is not being spawned
* Get test_show_debug_panel to pass & clean up
* Make clippy pass
* Assert debug panel item is removed when client shutdown
* Move send event back to dapstore
---------
Co-authored-by: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
The past version always returned an error when attempting to deserialize custom DAP
events. Causing Zed to stop recving messages from the debug adapter
Before this change, we always started a new adapter but this was causing some issues:
- Infinite client starts
- Cannot start client port already in use
- Not able to start a debug session
Co-Authored-By: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
The GDB adapter was failing because an stderr stream failed to
connect to Zed from the adapter. We now log the error and continue
the debugging sequence if std input and output streams connect.
* Move process to transport struct itself
* Add test to make sure we can send request and receive a response
* Align other handle methods
* Fix issues inside cargo.toml require test features inside the correct *-dependencies
* Remove comments that are not needed
* Add as_fake instead of downcasting
* Clean up
* Override get_binary method so we don't fail on install
* Fix false positive clippy error
This error was a match variant not being covered when the variant wasn't possible dued
to a feature flag. I'm pretty sure this is a bug in clippy/rust-analyzer and will
open an issue on their repos
* Remove not needed clone
* Panic when we receive an event/reverse request inside the test
* reuse the type of the closure
* Add a way to fake receiving events
* Oops remove fake event from different test
* Clipppyyyy
---------
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
* Rework download adapters and allow multiple download formats
* Move version path check up, so we don't have to check always 2 paths
* Add user installed binary back
* Fix dynamic ports don't work for javascript when using start debugging path
* Sync breakpoints on toggle to other client
* WIP Seperate local/remote in dap store
* WIP initial breakpoints sync
Co-Authored-By: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
* Get zed to compile
* Don't remove dap data when you unshare
* Add breakpoints table migration
* Update collab db when changing breakpoints
* Store breakpoints inside collab db when you change them
* Clean up
* Fix incorrect clearing of breakpoints during collab sync
* Get breakpoints to sync correctly on project join
We now send SynchronizedBreakpoints within the JoinProjectResponse
and use those breakpoints to initialize a remote DapStore.
* Set breakpoints from proto method
---------
Co-authored-by: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
The php adapter hangs when you click to fast on the UI buttons, so waiting 15 seconds before the request timeout was reached is a bit to much. Because after the timeout you can still continue the debug session.
This also fixes that we did not see the initial debug tasks defined in `initial_debug_tasks.json`. So new users should see at least these debug tasks the could run, without having to define them their selfs.
* Fix log breakpoint output bug when hit before any breakpoints
* Fix always push to output queue
* Don't pop output queue
We still want all the output in new threads
* Fix clippy error
---------
Co-authored-by: Remco Smits <djsmits12@gmail.com>
I added this it fix the race issue with session exited without stopping on a breakpoint. Turns out the adapter was sending these events for other threads that where not visible.
* Add allow users to ignore breakpoints
* Add different colors for both states
* Add source name for breakpoints
* Move ignore breakpoints to dap store
* Change icon instead of color
* Add action for ignore breakpoints for a client
* Remove spacing
* Fix compile error
* Return task instead of detaching itself
* Go DAP WIP
* Start work on getting go adapter working
* Get beta version of go adapter working & fix breakpoint line msgs
This adapter only works if a user has Go & delve in their PATH. It doesn't automatically download & updates itself because the official download process from the Delve docs would add delve to a user's PATH. I want to discuss with the Zed dev team & Remco if that is behavior we're ok with because typical downloads don't affect a user's PATH.
This PR also fixes a bug where some breakpoint line numbers were incorrect when sending to active DAP servers.
schemars seems to have a bug when generating schema for a struct with more than
one flatten field. Only the first flatten field works correctly and the second
one doesn't show up in the schema.
This was done to simplify the process of setting up a debug task and improve task organization.
This commit also improves parsing of debug.json so it's able to ignore misconfiguration debug tasks
instead of failing and returning no configured tasks
* Rename StopDebugAdapters to ShutdownDebugAdapters
* Remove debug config from install methods
* Move requests methods to background executor
* Wip attach with picker
* Move find client to the first line of the method
The client should always be there at this point.
* Fix correctly determine when to restart
While debugging an reverse request issue, the top level client did send terminated event with `restart: false` but we tried to restart the client resulting in the client never being cleaned up by us.
Because before this change we always assumed if we got a json value we are going to restart the client, which is wrong.
We no try to restart the client if:
- restart arg is a boolean and its true
- restart arg is a json value but no boolean
* Clean up response to adapter
* Fix clippy errors
* WIP tasks
* Simplified debug task schema
This changes debug.json to look for adapter: adapter_name instead of
and object when a user selects a debug adatper and fixes the default
behavior of request (to launch)
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Make default and flatten work for request
* Rename enum case
* Remove dbg
* Dismiss when candidate is not found
* Add docs for why we update the process id on the config
* Show error when `attach` request is selected but not supported
---------
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
* Remove space in cargo.toml
* Add TCPHost for Javascript and PHP adapter
* Allow falling back to first open port
* Add some more docs to TCPHost
* Fix cached binaries prevent from having multiple debug sessions for one adapters
This was an issue, because we stored the port arg inside the DebugAdapterBinary which was cached so could not change anymore.
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
* Add default setting for tcp timeout
Co-Authored-By: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
---------
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
* Begin integrating languages with DAP
* Add dap status type to activity indicator
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Show dap status to users
* Change Status enum to use ServerStatus struct in activity indicator
---------
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Correctly invalidate and refetch data
* Fix show current stack frame after invalidating
* Remove not used return value
* Clean up
* Don't send SelectedStackFrameChanged when id is still the same
* Only update the active debug line if we got the editor
* Get debug adapter to update when new versions are avaliable
* Debug adapter download only happens if there's a new version avaliable
* Use DebugAdapter.name() instead of string literals
* Fix bug where some daps wouldn't update/install correctly
* Clean up download adapter from github function
* Add debug adapter caching
* Add basic notification event to dap_store
* Clean up dap adapter install_binary functions
* Get lldb-dap working when on macos
* Add release tag to name of downloaded DAPs
* Check if adapter is already installed before installing one
* Implement RPC logging for debug adapter clients
* Implement server logs for debugger servers
* This cleans up the way we pass through the input and output readers for logging. So not each debug adapters have to map the AdapterLogIO fields. I also removed some specific when has logs from the client, because the client is not responsible for that. Removed an not needed/duplicated dependency Fix formatting & clippy
This cleans up the way we pass through the input and output readers for logging. So not each debug adapters have to map the AdapterLogIO fields.
I also removed some specific when has logs from the client, because the client is not responsible for that.
Removed an not needed/duplicated dependency
Fix formatting & clippy
* Implement `has_adapter_logs` for each transport impl
* Make adapter stdout logging work
* Add conditional render for adapter log back
* Oops forgot to pipe the output
* Always enable rpc messages
Previously, RPC messages were only stored when explicitly enabled, which occurred after the client was already running. This approach prevented debugging of requests sent during the initial connection period. By always enabling RPC messages, we ensure that all requests, including those during the connection phase, are captured and available for debugging purposes.
This could help use debug when someone has troble getting a debug starting. This improvement could be particularly helpful in debugging scenarios where users encounter issues during the initial connection or startup phase of their debugging sessions.
---------
Co-authored-by: Remco Smits <djsmits12@gmail.com>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
* Move how we connect to an debug adpater to the transport layer
This PR cleans up how we connect to a debug adapter.
Previously, this was done inside the debug adapter implementation.
While reviewing the debugger RPC log view PR,
I noticed that we could simplify the transport/client code,
making it easier to attach handlers for logging RPC messages.
* Remove not needed async block
* Change hardcoded delay before connecting to tcp adapter to timeout approach
Co-Authored-By: Anthony Eid <hello@anthonyeid.me>
---------
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
* Make program optional in debug task format
* Remove default config for skipFile JavaScript debugger
* Add Debug case to TerminalKind
* Don't allow serializing debug terminals
* Add respond method so we can send response back for reverse requests
* Implement run in terminal reverse request
* Move client calls to dap store
This commit also fixes an issue with not sending a response for the `StartDebugging` reverse request.
* Make clippy happy
* Remove not needed notify
* Add loaded sources list
* Remove not needed double nested div.child()
* Remove not needed block
* Fix todo for updating loaded source
Before this change the debug panel was still in the running state, which is/was wrong. So updating the status to Ended, will update the UI to an correct state.
* Clean up how adapters install and fetch their binary
Before this was in one method, which was hard to read and doing to many things.
* Add javascript debug adapter
* Get node binary from node_runtime
* Undo remove request args for lldb
* Remove initialize value for now
* Remove default values
* Fix did not compile javascript
* Fix php did not build
* Pass http client to dap store
* Set up DapAdapterDelegate to use for DAP binary fetches
* WIP to get debug adapters to use zed directory for installs
* Get debugpy automatic download working
* Change DapAdapter fetch_or_install to return a Result
* Add node_runtime to dap delegate
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Create dap_adapter crate & move language dap adapter code to that crate
This is the first phase of dap::client refactor to organize debug adapters with zed lsp adapters.
Eventually dap::client will have a TransportParams pass to it instead of an adapter, and adapters
will handle custom debug events.
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Move language specific dap adapter code to their own files
* Move DebugAdapter member out of ClientDebugAdapter struct
This change was done to make dap::client more in line with zed's lsp::client, it might be reverted depending
on if this solution is cleaner or not.
* Get php debug adapter to auto download when needed
* Get adapter_path argument to work with auto download dap adapters
---------
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* WIP Move stack frame list to own module
* Add missing notify
* Remove some more duplicated state for the current stack frame
* Clear highlights when stack frame has changed
* Fix go to stack frame again
* Create basic breakpoint prompt editor structure
* Get breakpoint prompt to properly render
* Fix bug where toggle breakpoint failed to work
This bug occurs when a breakpoint anchor position is moved from the begining
of a line. This causes dap_store.breakpoint hashmap to fail to properly get
the correct element, thus toggling the wrong breakpoint.
The fix to this bug is passing a breakpoint anchor to an editor's display map
and to the render breakpoint function. Instead of creating a new anchor when
clicking on a breakpoint icon, zed will use the breakpoint anchor passed to
the display map.
In the case of using toggle breakpoint action, zed will iterate through all
breakpoints in that buffer to check if any are on the cursor's line number,
then use anchor if found. Otherwise, zed creates a new anchor.
* Fix bug where breakpoint icon overlaps with other icons
This bug happened when an icon {code action | code runner} was rendered on the same line of a breakpoint
where that breakpoint's anchor was not at the start of the line
* Get breakpoint prompt to add log breakpoint's correctly
* Clean up breakpoint prompt UI & allow editting of log messages
---------
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Use buffer settings for font, size etc.
* Trim end of message
* By default send the output values to the output editor
* WIP send evaluate request
* Rename variable
* Add result to console from evaluate response
* Remove not needed arc
* Remove store capabilities on variable_list
* Specify the capacity for the task vec
* Add placeholder
* WIP add completion provider for existing variables
* Add value to auto completion label
* Make todo for debugger
* Specify the capacity of the vec's
* Make clippy happy
* Remove not needed notifies and add missing one
* WIP move scopes and variables to variable_list
* Rename configuration done method
* Add support for adapter completions and manual variable completions
* Move type to variabel_list
* Change update to read
* Show debug panel when debug session stops
Co-Authored-By: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
Co-Authored-By: Mikayla Maki <mikayla.c.maki@gmail.com>
* Also use scope reference to determine to which where the set value editor should display
* Refetch existing variables after
* Rebuild entries after refetching the variables
---------
Co-authored-by: Anthony Eid <56899983+Anthony-Eid@users.noreply.github.com>
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
* Only include dap store if editor.mode is FULL
* Move go to stack frame to debug_panel_item
* Notify dap_store when updating active breakpoints location
* Fix clippyyyy
* Show active debug line when you reopen a buffer
* Remove uncommented code
This is not needed anymore, we already clear the highlights when thread exited
* Make clippy happy
* Fix todo for removing highlights on exited event
This PR moves out all the actions from the **debug_panel_item** to the **workspace** which allows people to use these actions inside their key binds.
I also had to remove the debug_panel dependency inside the debug_panel_item, because we hit a `"cannot update debug_panel while it is already being updated"` panic. So instead of updating the thread status inside the **debug_panel** we now do this inside the **debug_panel_item** to prevent this panic.
I also move the actions to its own debugger namespace, so it's more clear what the actions are for.
The new actions can now also be used for key binds:
```
debugger: start
debugger: continue
debugger: step into
debugger: step over
debugger: step out
debugger: restart
debugger: stop
debugger: pause
```
/cc @Anthony-Eid We now can have key binds for debugger actions.
* Make dap store global
* Partially move initialize & capability code to dap store
* Reuse shutdown for shutdown clients
* Rename merge_capabilities
* Correctly fallback to current thread id for checking to skip event
* Move mthod
* Move terminate threads to dap store
* Move disconnect and restart to dap store
* Update dap-types to the correct version
This includes the capabilities::merge method
* Change dap store to WeakModel in debug panels
* Make clippy happy
* Move pause thread to dap store
* WIP refactor out thread state and capbilities
* Move update thread status to debug panel method
* Remove double notify
* Move continue thread to dap store
* Change WeakModel dapStore to Model dapStore
* Move step over to dap store
* Move step in to dap store
* Move step out to dap store
* Remove step back
we don't support this yet
* Move threadState type to debugPanel
* Change to background task
* Fix panic when debugSession stopped
* Remove capabilities when debug client stops
* Add missing notify
* Remove drain that causes panic
* Remove Arc<DebugAdapterClient> from debug_panel_item instead use the id
* Reset stack_frame_list to prevent crash
* Refactor ThreadState to model to prevent recursion dependency in variable_list
* WIP
* WIP move set_variable_value and get_variables to dap store
* Remove unused method
* Fix correctly insert updated variables
Before this changes you would see the variables * scopes. Because it did not insert the the variables per scope.
* Correctly update current stack frame on variable list
* Only allow building variable list entries for current stack frame
* Make toggle variables & scopes work again
* Fix clippy
* Pass around id instead of entire client
* Move set breakpoints to dap store
* Show thread status again in tooltip text
* Move stack frames and scope requests to dap store
* Move terminate request to dap store
* Remove gap that is not doing anything
* Add retain back to remove also threads that belong to the client
* Add debug kind back to tab content
This also changes the concept of passing the receiver inside the request to make sure we handle all the requests in the right order.
Now we have another peace of state that keeps track of the current requests, and when request comes in we move the receiver to the pending requests state and handle the request as we did before.
This is done by making breakpoint.position field optional and
adding a cached_position field too. I also added dap_store to
buffer_store and got buffer_store to initialize breakpoints
when a new buffer is opened. Fixing a bug where some breakpoints
wouldn't appear within multi buffers
This fixes a crash that happened when placing a breakpoint within a multi buffer
where it's excerpt_id != 1.
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Start setting up new debug task format
* Set up blueprint for converting from debug task to regular task
* Create debug adapter trait
* Get debug.json schema to json lsp to show users hints
* Start debugger task refactor to enable easier debugger setup
* Get python adapter to work within task.json
co-authored-by: Piotr <piotr@zed.dev>
* Start work on getting Php Debug adapter working
* Make debug adapter trait work with async functions
Fix CICD spell check & clippy warnings
Co-authored-by: Remco Smits <djsmits12@gmail.com>
---------
Co-authored-by: Piotr <piotr@zed.dev>
Co-authored-by: Remco Smits <djsmits12@gmail.com>
* Move breakpoint and client code to dap store
This also changes how we sync breakpoints. Now we just update the dap store model instead of having a RWlock.
The goal is to prepare for making inlay hints for debugging work.
* Remove debug code
* Remove unused method
* Fix don't grow the amount tasks for sending all the breakpoints
* Partially implement terminate clients when app quits
* Sync open breakpoints to closed breakpoints when buffer is closed
* Call terminate request also for not already started clients
* Fix missing import
* Remove not needed read_with call
* Wip render set variable value editor
* Remove unused subscriptions
* Set current variable value & select all when setting value
* Send set variable request
* Rename tread entry to VariableListEntry
* WIP allow setting variables for nested structures
* Refactor & rename vars on thread state to be only the ids
* Fix we did not correct notify the right context when updating variable list
* Clean open entries when debugger stops
* Use SetExpression if adapter supports it when setting value
* Refetch scope variables after setting value
This commit also reworks how we store scopes & variables
* Remove debug code
* Make Clippy happy
* Rename variable
* Change order for variable id
* Allow cancelling set value using escape key
* Create debugger console
* Get console to output console messages during output events
* Use match expression in handle_output_event
* Move debug console code to it's own file console
* Only clear highlights op open tabs
This much better so we don't have to open each path of each stack frame in each thread.
* Don't open the same file twice for clearing thread highlights
* Lazy fetch
* Remove unused code
* Clean up fetch nested variable
* Include scope id for variable id to be more unique
* Clean up not needed get_mut function calls
* WIP Show variables in toggable list items
* Use more unique element id so we can group variables by name and reference
* Fix correct pass in listItem toggle value
* Fix we did not set the current stack frame id
* WIP start fetching variables recursively
* Remove duplicated code for current stack frame id
* Fetch all variables for each stack frame parallel
* Fetch all variable on the same level parallel
* Rename vars so its more clear
* Refactor how we store thread data
We now store the information in a better way so we could filter on it easier and faster.
* Remove unused code
* Use stack frame id as top level key instead of struct itself
* Add has_children to scope thread entry
* Fix allow switching current stack frame
Also fixed building list entries twice right after each other
* Show message when scope does not have variables
* Remove scope if it does not have variables
* Add allow collapsing scopes
* Add allow collapsing variables
* Add docs to determine collapsed variables
* Allow collapsing variables and always show first scope variables
* Correctly fix collapse variables
* Fix clippy
We shouldn't consider a debugger active until it's running because it may fail during it's starting phase.
Also, this check is used determine if we should update a file's breakpoints when one is toggled.
Code action's that overlap with breakpoints will now show as red. Still need to
add a code action to toggle a breakpoint & handle overlaps with code runners
I also made a new DS specifically for breakpoints that aren't part of any open buffers.
It should be easier to serialize and deserialize breakpoints now.
* Fix used wrong request args in set breakpoints request
Some debug adapters depend on getting the exact data that you passed in `launch` or `attach` request.
* Send correct request for stopping debug adapter
I changed the name to be more in line with the request name. We now also send the correct request values on the `support_terminate_debuggee` and `support_terminate_debuggee` capabilities.
* Send disconnect request for terminate threads if it does not support it
* Only send configuration done request if its supported
* Add disconnect icon
* Only send step over request params when adapter supports it
* Only send resume(continue) request params if adapter supports it
* Step in only send request args if adapter supports it
* Step out only send request args if adapter supports it
* Step back only send request args if adapter supports it
* Log error using `detach_and_log_err` instead of manually
* Wip move handle reverse requests on the debug panel
* Remove todo for startDebugging
* Remove unused code
* Make clippy happy
* Log error instead of ignoring it
* Remove debug code
This pull request enables users to set breakpoints by clicking to the left of a line number within editor. It also anchor's breakpoints to the original line they were placed on, which allows breakpoints to stay in their relative position when a line before a breakpoint is removed/added.
The crash was happening because editor was trying to render all breakpoints even if they didn't
belong to the current buffer. Breakpoint don't persistent after closing a tab, will need to
change the breakpoint DS key from buffer_id to something more permament
The end goal of this commit is to allow a user to set a breakpoint by
hovering over a line in the editor's gutter. Currently breakpoints
only show on line 6 when the mouse is on a gutter.
Instead of editor sharing with project each time a breakpoint is toggled. An
editor will clone project's breakpoints if a project is passed into the editors
new function
Previously editor would send breakpoints to project whenever
a new breakpoint was deleted or added. Now editor shares a
shared pointer to a breakpoint datastructure. This behavior
is more efficient because it doesn't have to repeatly send
breakpoints everytime one is updated.
Still have to handle cases when a breakpoint is added/removed during
a debugging phase. I also have to figure out how to share the breakpoints
pointer only once per project and editor.
* Add support for DAP to use std for communication
* Add more descriptive error logs for DAP
* Implement handler for continued event
* Add PR feedback to handle_continued_event function
* Updated debugger
* Fix race condition when using late case debug adapters
The main thing this commit does is fix race conditions between a
dap client's event handler and sending a launch/attach request.
Some adapters would only respond to a starting request after the
client handled an init event, which could never happen because
the client used to start it's handler after it sent a launch request.
This commit also ignores undefined errors instead of crashing. This
allows the client to work with adapters that send custom events.
Finially, I added some more descriptive error messages and change
client's starting request seq from 0 to 1 to be more in line with
the specs.
* Get clippy to run successfully
* Add some function docs to dap client
* Fix debugger's highlight when stepping through code
Merging with the main zed branch removed a function that
the debugger panel relied on. I added the function back
and changed it to work with the updated internals of zed.
* Get clippy to pass & add an error log instead of using dbg!()
* Get sequence id to be incremented after getting respond and event
---------
Co-authored-by: Remco Smits <djsmits12@gmail.com>
Breakpoints are now stored in a BTreeMap<buffer_id, HashSet<Breakpoint>>
I did this becauase we need to constant check if a breakpoint exists in
a buffer whenever we toggle one.
Merging with the main zed branch removed a function that
the debugger panel relied on. I added the function back
and changed it to work with the updated internals of zed.
We have to read them as early as possible to make sure we support more debug adapters. Some of them wait before you handled the initialized event. That is also why I moved the launch/attach request to be directly after the initialize request. For example the xdebug adapter sends the initialized event only when you send the launch request, so before if we send the breakpoints and configuration is done requests the adapter would stop and all channels were closed.
The main thing this commit does is fix race conditions between a
dap client's event handler and sending a launch/attach request.
Some adapters would only respond to a starting request after the
client handled an init event, which could never happen because
the client used to start it's handler after it sent a launch request.
This commit also ignores undefined errors instead of crashing. This
allows the client to work with adapters that send custom events.
Finially, I added some more descriptive error messages and change
client's starting request seq from 0 to 1 to be more in line with
the specs.
Not all the debug adapters send the continue event so we couldn't determine that the thread state status was `running`. So we have to determine it our selfs if the thread state status did not change, if so we change the status to `running`.
This allows us to show the pause button when the thread state status is running, so you can pause the programs execution.
* Add support for DAP to use std for communication
* Add more descriptive error logs for DAP
* Implement handler for continued event
* Add PR feedback to handle_continued_event function
This fixes an issue that not all debuggers send the `thread` event and we assumed that we always know the thread inside the handling code of the `stopped` event.
This is a temporary fix, so we don't crash when race condition occurs and the event is send earlier than request was finished. The debug adapter was still `starting` meaning the task was still pending.
This fixes an issue that the debugger adapter was notified to early. So it had in correct breakpoint information and would always stop on the first line without given a stack trace
The debugger config inventory is used to track config files for the debugger. Currently, only .zed/debug.json is set up to work, but it's still untested.
* Prioritize code correctness and clarity. Speed and efficiency are secondary priorities unless otherwise specified.
* Do not write organizational or comments that summarize the code. Comments should only be written in order to explain "why" the code is written in some way in the case there is a reason that is tricky / non-obvious.
* Prefer implementing functionality in existing files unless it is a new logical component. Avoid creating many small files.
* Avoid using functions that panic like `unwrap()`, instead use mechanisms like `?` to propagate errors.
* Be careful with operations like indexing which may panic if the indexes are out of bounds.
* Never silently discard errors with `let _ =` on fallible operations. Always handle errors appropriately:
- Propagate errors with `?` when the calling function should handle them
- Use `.log_err()` or similar when you need to ignore errors but want visibility
- Use explicit error handling with `match` or `if let Err(...)` when you need custom logic
* When implementing async operations that may fail, ensure errors propagate to the UI layer so users get meaningful feedback.
* Never create files with `mod.rs` paths - prefer `src/some_module.rs` instead of `src/some_module/mod.rs`.
# GPUI
GPUI is a UI framework which also provides primitives for state and concurrency management.
## Context
Context types allow interaction with global state, windows, entities, and system services. They are typically passed to functions as the argument named `cx`. When a function takes callbacks they come after the `cx` parameter.
* `App` is the root context type, providing access to global state and read and update of entities.
* `Context<T>` is provided when updating an `Entity<T>`. This context dereferences into `App`, so functions which take `&App` can also take `&Context<T>`.
* `AsyncApp` and `AsyncWindowContext` are provided by `cx.spawn` and `cx.spawn_in`. These can be held across await points.
## `Window`
`Window` provides access to the state of an application window. It is passed to functions as an argument named `window` and comes before `cx` when present. It is used for managing focus, dispatching actions, directly drawing, getting user input state, etc.
## Entities
An `Entity<T>` is a handle to state of type `T`. With `thing: Entity<T>`:
* `thing.update(cx, |thing: &mut T, cx: &mut Context<T>| ...)` allows the closure to mutate the state, and provides a `Context<T>` for interacting with the entity. It returns the closure's return value.
* `thing.update_in(cx, |thing: &mut T, window: &mut Window, cx: &mut Context<T>| ...)` takes a `AsyncWindowContext` or `VisualTestContext`. It's the same as `update` while also providing the `Window`.
Within the closures, the inner `cx` provided to the closure must be used instead of the outer `cx` to avoid issues with multiple borrows.
Trying to update an entity while it's already being updated must be avoided as this will cause a panic.
When `read_with`, `update`, or `update_in` are used with an async context, the closure's return value is wrapped in an `anyhow::Result`.
`WeakEntity<T>` is a weak handle. It has `read_with`, `update`, and `update_in` methods that work the same, but always return an `anyhow::Result` so that they can fail if the entity no longer exists. This can be useful to avoid memory leaks - if entities have mutually recursive handles to eachother they will never be dropped.
## Concurrency
All use of entities and UI rendering occurs on a single foreground thread.
`cx.spawn(async move |cx| ...)` runs an async closure on the foreground thread. Within the closure, `cx` is an async context like `AsyncApp` or `AsyncWindowContext`.
When the outer cx is a `Context<T>`, the use of `spawn` instead looks like `cx.spawn(async move |handle, cx| ...)`, where `handle: WeakEntity<T>`.
To do work on other threads, `cx.background_spawn(async move { ... })` is used. Often this background task is awaited on by a foreground task which uses the results to update state.
Both `cx.spawn` and `cx.background_spawn` return a `Task<R>`, which is a future that can be awaited upon. If this task is dropped, then its work is cancelled. To prevent this one of the following must be done:
* Awaiting the task in some other async context.
* Detaching the task via `task.detach()` or `task.detach_and_log_err(cx)`, allowing it to run indefinitely.
* Storing the task in a field, if the work should be halted when the struct is dropped.
A task which doesn't do anything but provide a value can be created with `Task::ready(value)`.
## Elements
The `Render` trait is used to render some state into an element tree that is laid out using flexbox layout. An `Entity<T>` where `T` implements `Render` is sometimes called a "view".
Since `impl IntoElement for SharedString` exists, it can be used as an argument to `child`. `SharedString` is used to avoid copying strings, and is either an `&'static str` or `Arc<str>`.
UI components that are constructed just to be turned into elements can instead implement the `RenderOnce` trait, which is similar to `Render`, but its `render` method takes ownership of `self`. Types that implement this trait can use `#[derive(IntoElement)]` to use them directly as children.
The style methods on elements are similar to those used by Tailwind CSS.
If some attributes or children of an element tree are conditional, `.when(condition, |this| ...)` can be used to run the closure only when `condition` is true. Similarly, `.when_some(option, |this, value| ...)` runs the closure when the `Option` has a value.
## Input events
Input event handlers can be registered on an element via methods like `.on_click(|event, window, cx: &mut App| ...)`.
Often event handlers will want to update the entity that's in the current `Context<T>`. The `cx.listener` method provides this - its use looks like `.on_click(cx.listener(|this: &mut T, event, window, cx: &mut Context<T>| ...)`.
## Actions
Actions are dispatched via user keyboard interaction or in code via `window.dispatch_action(SomeAction.boxed_clone(), cx)` or `focus_handle.dispatch_action(&SomeAction, window, cx)`.
Actions which have no data inside are created and registered with the `actions!(some_namespace, [SomeAction, AnotherAction])` macro call.
Actions that do have data must implement `Clone, Default, PartialEq, Deserialize, JsonSchema` and can be registered with an `impl_actions!(some_namespace, [SomeActionWithData])` macro call.
Action handlers can be registered on an element via the event handler `.on_action(|action, window, cx| ...)`. Like other event handlers, this is often used with `cx.listener`.
## Notify
When a view's state has changed in a way that may affect its rendering, it should call `cx.notify()`. This will cause the view to be rerendered. It will also cause any observe callbacks registered for the entity with `cx.observe` to be called.
## Entity events
While updating an entity (`cx: Context<T>`), it can emit an event using `cx.emit(event)`. Entities register which events they can emit by declaring `impl EventEmittor<EventType> for EntityType {}`.
Other entities can then register a callback to handle these events by doing `cx.subscribe(other_entity, |this, other_entity, event, cx| ...)`. This will return a `Subscription` which deregisters the callback when dropped. Typically `cx.subscribe` happens when creating a new entity and the subscriptions are stored in a `_subscriptions: Vec<Subscription>` field.
## Recent API changes
GPUI has had some changes to its APIs. Always write code using the new APIs:
* `spawn` methods now take async closures (`AsyncFn`), and so should be called like `cx.spawn(async move |cx| ...)`.
* Use `Entity<T>`. This replaces `Model<T>` and `View<T>` which no longer exist and should NEVER be used.
* Use `App` references. This replaces `AppContext` which no longer exists and should NEVER be used.
* Use `Context<T>` references. This replaces `ModelContext<T>` which no longer exists and should NEVER be used.
* `Window` is now passed around explicitly. The new interface adds a `Window` reference parameter to some methods, and adds some new "*_in" methods for plumbing `Window`. The old types `WindowContext` and `ViewContext<T>` should NEVER be used.
On macOS and Linux you can [download Zed directly](https://zed.dev/download) or [install Zed via your local package manager](https://zed.dev/docs/linux#installing-via-a-package-manager).
<pathd="M 808.592 158.131 C 807.489 158.131 806.592 157.234 806.592 156.131 C 806.592 155.028 807.489 154.131 808.592 154.131 C 809.695 154.131 810.592 155.028 810.592 156.131 C 810.592 157.234 809.695 158.131 808.592 158.131 Z M 776.705 185.039 L 773.457 183.145 L 780.122 178.979 L 779.062 177.283 L 771.505 182.006 L 765.592 178.557 L 765.592 169.666 L 771.147 165.963 L 770.037 164.299 L 764.551 167.956 L 758.592 164.551 L 758.592 159.711 L 765.088 155.999 L 764.096 154.263 L 758.592 157.408 L 758.592 153.711 L 764.592 150.283 L 770.592 153.711 L 770.592 157.565 L 766.077 160.274 L 767.107 161.988 L 771.592 159.297 L 776.077 161.988 L 777.107 160.274 L 772.592 157.565 L 772.592 153.666 L 778.147 149.963 C 778.425 149.777 778.592 149.465 778.592 149.131 L 778.592 142.131 L 776.592 142.131 L 776.592 148.596 L 771.551 151.956 L 765.592 148.551 L 765.592 139.705 L 770.592 136.789 L 770.592 145.131 L 772.592 145.131 L 772.592 135.622 L 776.705 133.223 L 784.592 135.852 L 784.592 164.565 L 770.077 173.274 L 771.107 174.988 L 784.592 166.897 L 784.592 182.41 L 776.705 185.039 Z M 806.592 169.131 C 806.592 170.234 805.695 171.131 804.592 171.131 C 803.489 171.131 802.592 170.234 802.592 169.131 C 802.592 168.028 803.489 167.131 804.592 167.131 C 805.695 167.131 806.592 168.028 806.592 169.131 Z M 796.592 179.131 C 796.592 180.234 795.695 181.131 794.592 181.131 C 793.489 181.131 792.592 180.234 792.592 179.131 C 792.592 178.028 793.489 177.131 794.592 177.131 C 795.695 177.131 796.592 178.028 796.592 179.131 Z M 795.592 139.131 C 795.592 138.028 796.489 137.131 797.592 137.131 C 798.695 137.131 799.592 138.028 799.592 139.131 C 799.592 140.234 798.695 141.131 797.592 141.131 C 796.489 141.131 795.592 140.234 795.592 139.131 Z M 808.592 152.131 C 806.733 152.131 805.181 153.411 804.734 155.131 L 786.592 155.131 L 786.592 150.131 L 797.592 150.131 C 798.145 150.131 798.592 149.683 798.592 149.131 L 798.592 142.989 C 800.312 142.542 801.592 140.989 801.592 139.131 C 801.592 136.925 799.798 135.131 797.592 135.131 C 795.386 135.131 793.592 136.925 793.592 139.131 C 793.592 140.989 794.872 142.542 796.592 142.989 L 796.592 148.131 L 786.592 148.131 L 786.592 135.131 C 786.592 134.7 786.317 134.319 785.908 134.182 L 776.908 131.182 C 776.634 131.092 776.336 131.122 776.088 131.267 L 764.088 138.267 C 763.78 138.446 763.592 138.776 763.592 139.131 L 763.592 148.551 L 757.096 152.263 C 756.784 152.441 756.592 152.772 756.592 153.131 L 756.592 165.131 C 756.592 165.49 756.784 165.821 757.096 165.999 L 763.592 169.711 L 763.592 179.131 C 763.592 179.486 763.78 179.816 764.088 179.995 L 776.088 186.995 C 776.242 187.085 776.417 187.131 776.592 187.131 C 776.698 187.131 776.805 187.114 776.908 187.08 L 785.908 184.08 C 786.317 183.943 786.592 183.562 786.592 183.131 L 786.592 171.131 L 793.592 171.131 L 793.592 175.273 C 791.872 175.72 790.592 177.273 790.592 179.131 C 790.592 181.337 792.386 183.131 794.592 183.131 C 796.798 183.131 798.592 181.337 798.592 179.131 C 798.592 177.273 797.312 175.72 795.592 175.273 L 795.592 170.131 C 795.592 169.579 795.145 169.131 794.592 169.131 L 786.592 169.131 L 786.592 164.131 L 799.092 164.131 L 801.23 166.981 C 800.831 167.603 800.592 168.338 800.592 169.131 C 800.592 171.337 802.386 173.131 804.592 173.131 C 806.798 173.131 808.592 171.337 808.592 169.131 C 808.592 166.925 806.798 165.131 804.592 165.131 C 803.908 165.131 803.274 165.319 802.711 165.623 L 800.392 162.531 C 800.203 162.279 799.906 162.131 799.592 162.131 L 786.592 162.131 L 786.592 157.131 L 804.734 157.131 C 805.181 158.851 806.733 160.131 808.592 160.131 C 810.798 160.131 812.592 158.337 812.592 156.131 C 812.592 153.925 810.798 152.131 808.592 152.131 Z"fill-rule="evenodd"fill-opacity="1"style=""id="object-0"transform="matrix(1, 0, 0, 1, -472.9506530761719, -3.7858259677886963)"/>
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.