Commit graph

88 commits

Author SHA1 Message Date
Piotr Osiewicz
6825715503
Another batch of lint fixes (#36521)
- **Enable a bunch of extra lints**
- **First batch of fixes**
- **More fixes**

Release Notes:

- N/A
2025-08-19 20:33:44 +00:00
Piotr Osiewicz
05fc0c432c
Fix a bunch of other low-hanging style lints (#36498)
- **Fix a bunch of low hanging style lints like unnecessary-return**
- **Fix single worktree violation**
- **And the rest**

Release Notes:

- N/A
2025-08-19 21:26:17 +02:00
Piotr Osiewicz
8f567383e4
Auto-fix clippy::collapsible_if violations (#36428)
Release Notes:

- N/A
2025-08-19 13:27:24 +00:00
Piotr Osiewicz
9e0e233319
Fix clippy::needless_borrow lint violations (#36444)
Release Notes:

- N/A
2025-08-18 21:54:35 +00:00
Piotr Osiewicz
9b78c46902
python: Use pip provided by our 'base' venv (#36414)
Closes #36218

Release Notes:

- Debugger: Python debugger installation no longer assumes that pip is
available in global Python installation
2025-08-18 14:48:38 +00:00
Piotr Osiewicz
39dfd52d04
python: Create DAP download directory sooner (#35986)
Closes #35980

Release Notes:

- Fixed Python Debug sessions not starting up when a session is started
up for the first time.
2025-08-11 16:50:24 +00:00
Lukas Wirth
e132c7cad9
dap_adapters: Log CodeLldb version fetching errors (#35943)
Release Notes:

- N/A
2025-08-11 08:15:59 +00:00
Piotr Osiewicz
fc2ba82eb6
debugpy: Fetch a wheel into Zed's work dir and use that with users venv (#35640)
Another stab at #35388
cc @Sansui233

Closes #35388

Release Notes:

- debugger: Fixed Python debug sessions failing to launch due to a
missing debugpy installation.
2025-08-05 19:09:42 +02:00
Piotr Osiewicz
afc4f50300
debugger: Ensure that Python's adapter work dir exists (#35618)
Closes #ISSUE

cc @Sansui233 who triaged this in
https://github.com/zed-industries/zed/issues/35388#issuecomment-3146977431
Release Notes:

- debugger: Fixed an issue where a Python debug adapter could not be
installed when debugging Python projects for the first time.
2025-08-04 22:51:40 +00:00
Piotr Osiewicz
91bbdb7002
debugger: Install debugpy into user's venv if there's one selected (#35617)
Closes #35388


Release Notes:

- debugger: Fixed Python debug sessions failing to launch due to a
missing debugpy installation. Debugpy is now installed into user's venv
if there's one available.
2025-08-05 00:37:06 +02:00
Piotr Osiewicz
2ac99e7a11
debugger: Fix attaching with DebugPy (#34706)
@cole-miller found a root cause of our struggles with attach scenarios;
we did not fetch .so files necessary for attaching to work,
as we were downloading DebugPy source tarballs from GitHub.

This PR does away with it by setting up a virtualenv instead that has
debugpy installed.

Closes #34660
Closes #34575

Release Notes:

- debugger: Fixed attaching with DebugPy. DebugPy is now installed
automatically from pip (instead of GitHub), unless it is present in
active virtual environment. Additionally this should resolve any startup
issues with missing .so on Linux.
2025-07-18 14:28:03 +00:00
Cole Miller
0a3ef40c2f
debugger: Interpret user-specified debug adapter binary paths in a more intuitive way for JS and Python (#33926)
Previously we would append `js-debug/src/dapDebugServer.js` to the value
of the `dap.JavaScript.binary` setting and `src/debugpy/adapter` to the
value of the `dap.Debugpy.binary` setting, which isn't particularly
intuitive. This PR fixes that.

Release Notes:

- debugger: Made the semantics of the `dap.$ADAPTER.binary` setting more
intuitive for the `JavaScript` and `Debugpy` adapters. In the new
semantics, this should be the path to `dapDebugServer.js` for
`JavaScript` and the path to the `src/debugpy/adapter` directory for
`Debugpy`.

---------

Co-authored-by: Remco Smits <djsmits12@gmail.com>
2025-07-15 22:31:28 +00:00
Cole Miller
a8cc927303
debugger: Improve appearance of session list for JavaScript debugging (#34322)
This PR updates the debugger panel's session list to be more useful in
some cases that are commonly hit when using the JavaScript adapter. We
make two adjustments, which only apply to JavaScript sessions:

- For a child session that's the only child of a root session, we
collapse it with its parent. This imitates what VS Code does in the
"call stack" view for JavaScript sessions.
- When a session has exactly one thread, we label the session with that
thread's name, instead of the session label provided by the DAP. VS Code
also makes this adjustment, which surfaces more useful information when
working with browser sessions.

Closes #33072 

Release Notes:

- debugger: Improved the appearance of JavaScript sessions in the debug
panel's session list.

---------

Co-authored-by: Julia <julia@zed.dev>
Co-authored-by: Remco Smits <djsmits12@gmail.com>
2025-07-12 15:56:05 +00:00
Lukas Spiss
fbead09c30
go: Write envFile properties back to env config (#34300)
Closes https://github.com/zed-industries/zed/issues/32984

Note that while https://github.com/zed-industries/zed/pull/33666 did the
reading of the `envFile` just fine, the read values were never passed
along. This was mentioned by [this
comment](https://github.com/zed-industries/zed/pull/33666#issuecomment-3060785970)
and also confirmed by myself.

With the changes here, I successfully debugged a project of mine and all
the environment variables from my `.env` were present.

Release Notes:

- Fix Go debugger ignoring env vars from the envFile setting.
2025-07-11 18:26:46 +00:00
Piotr Osiewicz
4693f16759
debugger: Remove PHP debug adapter (#34020)
This commit removes the PHP debug adapter in favor of a new version
(0.3.0) of PHP extension.
The name of a debug adapter has been changed from "PHP" to "Xdebug",
which makes this a breaking change in user-configured scenarios

Release Notes:

- debugger: PHP debug adapter is no longer shipped in core Zed editor;
it is now available in PHP extension (starting with version 0.3.0). The
adapter has been renamed from `PHP` to `Xdebug`, which might break your
user-defined debug scenarios.
2025-07-08 01:36:32 +02:00
Remco Smits
01295aa687
debugger: Fix the JavaScript debug terminal scenario (#33924)
There were a couple of things preventing this from working:

- our hack to stop the node REPL from appearing broke in recent versions
of the JS DAP that started passing `--experimental-network-inspection`
by default
- we had lost the ability to create a debug terminal without specifying
a program

This PR fixes those issues. We also fixed environment variables from the
**runInTerminal** request not getting passed to the spawned program.

Release Notes:

- Debugger: Fix RunInTerminal not working for JavaScript debugger.

---------

Co-authored-by: Cole Miller <cole@zed.dev>
2025-07-05 19:48:55 -04:00
Cole Miller
543a7b123a
debugger: Fix errors in JavaScript DAP schema (#33884)
`program` isn't required, and in fact our built-in `JavaScript debug
terminal` configuration doesn't have it.

Also add `node-terminal` to the list of allowed types.

Co-authored-by: Michael <michael@zed.dev>

Release Notes:

- N/A
2025-07-04 13:33:10 -04:00
Cole Miller
38544e514a
debugger: Use debugpy's suggested names for child sessions (#33885)
Just like vscode-js-debug, debugpy uses the `name` key in
StartDebuggingRequestArguments for this:


0d65353cc6/src/debugpy/adapter/clients.py (L753)

Release Notes:

- debugger: Made the names of Python subprocesses in the session list
more helpful.
2025-07-04 00:15:02 +00:00
Cole Miller
82fac9da82
debugger: Always use runtimeExecutable for node-terminal scenarios (#33794)
cc @afgomez 

Release Notes:

- debugger: Fixed `node-terminal` debug configurations not working with
some commands.
2025-07-02 16:37:52 -04:00
Cole Miller
9d6b2e8a32
debugger: Don't take JS adapter's suggested child session name if it's empty (#33739)
Related to #33072 

We use the JS adapter's suggested names for child sessions, but
sometimes it sends us `""`, so don't use that one.

Release Notes:

- debugger: Fixed nameless child sessions appearing with the JavaScript
adapter.
2025-07-01 21:09:19 +00:00
Julia Ryan
0068de0386
debugger: Handle the envFile setting for Go (#33666)
Fixes #32984

Release Notes:

- The Go debugger now respects the `envFile` setting.
2025-07-01 09:14:59 -07:00
Piotr Osiewicz
2caa19214b
debugger: Do not include Rust in default value for sourceLanguages (CodeLLDB config) (#33670)
- **debugger: Update exception breakpoints list on capability update**
- **Do not prefill codelldb sourcelanguages by default**

Release Notes:

- debugger: CodeLLDB no longer enables pretty-printers for Rust by
default. This fixes pretty-printers for C++. This is a breaking change
for user-defined debug scenarios from debug.json; in order to enable
Rust pretty printing when using CodeLLDB, add `"sourceLanguages":
["rust"]` to your debug configuration. This change does not affect
scenarios automatically inferred by Zed.

---------

Co-authored-by: Anthony Eid <anthony@zed.dev>
2025-07-01 11:03:40 +00:00
Bedis Nbiba
abe5d523e1
dap_adapters: Add attachSimplePort to JS DAP schema (#31412)
taken from
https://github.com/microsoft/vscode-js-debug/blob/main/OPTIONS.md?plain=1

Release Notes:

- debugger: Added attachSimplePort to JavaScript DAP schema

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2025-07-01 12:28:01 +02:00
Julia Ryan
ce164f5e65
Remove ruby debug adapter (#33541)
Now that the extension version has been bumped we can remove our in-tree
one to avoid having duplicate debug adapters.

Release Notes:

- The ruby debug adapter has been moved to the [ruby
extension](https://github.com/zed-extensions/ruby), if you have any
saved debug scenarios you'll need to change `"adapter": "Ruby"` to
`"adapter": "rdbg"`.
2025-06-30 09:15:56 -07:00
Cole Miller
35863c4302
debugger: Fix treatment of node-terminal scenarios (#33432)
- Normalize `node-terminal` to `pwa-node` before sending to DAP
- Split `command` into `program` and `args`
- Run in external console

Release Notes:

- debugger: Fixed debugging JavaScript tasks that used `"type":
"node-terminal"`.
2025-06-26 14:02:09 -04:00
Anthony Eid
fc1fc264ec
debugger: Generate inline values based on debugger.scm file (#33081)
## Context

To support inline values a language will have to implement their own
provider trait that walks through tree sitter nodes. This is overly
complicated, hard to accurately implement for each language, and lacks
proper extension support.

This PR switches to a singular inline provider that uses a language's
`debugger.scm` query field to capture variables and scopes. The inline
provider is able to use this information to generate inlays that take
scope into account and work with any language that defines a debugger
query file.

### Todos
- [x] Implement a utility test function to easily test inline values
- [x] Generate inline values based on captures
- [x] Reimplement Python, Rust, and Go support
- [x] Take scope into account when iterating through variable captures
- [x] Add tests for Go inline values
- [x] Remove old inline provider code and trait implementations

Release Notes:

- debugger: Generate inline values based on a language debugger.scm file
2025-06-24 18:24:43 +00:00
Cole Miller
c9bd409732
debugger: Support passing custom arguments to debug adapters (#33251)
Custom arguments replace any arguments that we normally pass to the DAP.
For interpreted languages, they are passed to the interpreter after the
DAP path or module. They can be combined with a custom binary, or you
can omit `dap.binary` and just customize the arguments to the DAPs we
download.

This doesn't take care of updating the extension API to support custom
arguments.

Release Notes:

- debugger: Implemented support for passing custom arguments to a debug
adapter binary using the `dap.args` setting.
- debugger: Fixed not being able to use the `dap` setting in
`.zed/settings.json`.
2025-06-23 17:06:48 +00:00
Conrad Irwin
74aa227c09
Wait for source maps when setting TypeScript breakpoints (#32954)
Closes #ISSUE

Release Notes:

- debugger: Fix setting breakpoints in typescript code when debugging
compiled javascript
2025-06-18 11:12:16 -06:00
Piotr Osiewicz
a69ebf038a
debugger: Prevent port collision when attaching to existing node debugger (#32862)
We were translating port configuration incorrectly, using it for both
attach target and debugger port.
This however meant that we were spawning a 2nd process that'd listen on
the same port as the existing debugger.

Closes #32836

Release Notes:

- debugger: Fixed issues with auto-translated Visual Studio Code debug
configs for attaching to existing node debugger instances.
2025-06-17 13:22:32 +00:00
Piotr Osiewicz
336c49b10d
debuggers: Mark processId as optional field in Delve Attach configurations (#32856)
Closes #32849

Release Notes:

- Fixed overly strict validation of Go debugging configurations.
2025-06-17 11:18:37 +00:00
Piotr Osiewicz
0f0ff40c6d
extension: Another batch of updates for DAP extension API (#32809)
Closes #ISSUE

Release Notes:

- N/A
2025-06-16 21:34:05 +02:00
Conrad Irwin
92addb005a
Pass project environment to runInTerminal requests (#32720)
Closes #ISSUE

Release Notes:

- debugger: Pass environment to run in terminal requests
2025-06-16 09:34:50 -06:00
Piotr Osiewicz
8df6ce2aac
extension: Update DAP extension API (#32448)
- DAP schemas will be stored in `debug_adapters_schemas` subdirectory in
extension work dir.
- Added Debug Config integration and such.

Release Notes:

- N/A
2025-06-16 16:25:32 +02:00
Piotr Osiewicz
5923ba4992
debugger: Allow use of externally-managed Delve for Go debugging (#32613)
Closes #ISSUE

Release Notes:

- Go debug scenarios can now use an externally-managed Delve instance.
Use `tcp_connection` in your debug scenario definition to provide
adapter's address.
2025-06-12 15:27:44 +00:00
Cole Miller
1083c0ac53
debugger: Special-case npm et al. as program field for JS debug definitions (#32549)
Send `runtimeExecutable` and `runtimeArgs` instead of `program` and
`args` to avoid the DAP implicitly wrapping the command in `node`.

This means that putting `pnpm vitest <file>` as the command in the
launch modal will work, as will this in debug.json:

```
[
  {
    "adapter": "JavaScript",
    "type": "pwa-node",
    "label": "Label",
    "request": "launch",
    "program": "pnpm",
    "args": ["vitest", "<file>"],
    "cwd": "/Users/name/project"
  }
]
```


Release Notes:

- Debugger Beta: made it possible to use commands like `pnpm
<subcommand> <args>` in the launch modal and debug.json
2025-06-11 23:28:45 +00:00
Cole Miller
c4277681d1
debugger: Fix issues with launch.json handling (#32563)
After this PR we can run all the in-tree launch.json examples from [this
repo](https://github.com/microsoft/vscode-recipes).

Things done:

- Fill in default cwd at a lower level for all adapters
- Update launch.json parsing for DebugScenario changes
- Imitate how VS Code normalizes the `type` field for JS debug tasks
- Make version field optional
- Extend the variable replacer a bit

Release Notes:

- Debugger Beta: fixed issues preventing loading and running of debug
tasks from VS Code's launch.json.

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Anthony <anthony@zed.dev>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
2025-06-11 16:48:44 -04:00
Piotr Osiewicz
6c4728f00f
debugger: Mark DebugAdapterBinary::program as optional (#32534)
This allows us to support debugging with a debug adapter not managed by
Zed. Note that this is not a user facing change, as DebugAdapterBinary
is used to determine how to spawn a debugger. Thus, this should not
break any configs or anything like that.

Closes #ISSUE

Release Notes:

- N/A
2025-06-11 12:38:12 +02:00
Cole Miller
e0ca4270b4
debugger: Use JS adapter's suggested names for child sessions (#32474)
Also introduces an extension point for other adapters to do this if it
turns out they also send this information.

Release Notes:

- N/A (JS locator is still gated)
2025-06-10 14:24:43 -04:00
Conrad Irwin
3dfbd9e57c
Fix ruby debugger (#32407)
Closes #ISSUE

Release Notes:

- debugger: Fix Ruby (was broken by #30833)

---------

Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Piotr Osiewicz <peterosiewicz@gmail.com>
Co-authored-by: Cole Miller <m@cole-miller.net>
2025-06-09 16:11:24 -06:00
Piotr Osiewicz
d23359e19a
debugger: Fix issues with running Zed-installed debugpy + hangs when downloading (#32034)
Closes #32018

Release Notes:

- Fixed issues with launching Python debug adapter downloaded by Zed.
You might need to clear the old install of Debugpy from
`$HOME/.local/share/zed/debug_adapters/Debugpy` (Linux) or
`$HOME/Library/Application Support/Zed/debug_adapters/Debugpy` (Mac).
2025-06-04 01:37:25 +02:00
Piotr Osiewicz
a305eda8d1
debugger: Relax implementation of validate_config to not run validation (#31785)
When we moved to schema-based debug configs, we've added validate_config
- a trait method
that is supposed to both validate the configuration and determine
whether it is a launch configuration
or an attach configuration.

The validation bit is a bit problematic though - we received reports on
Discords about
scenarios not starting up properly; it turned out that Javascript's
implementation was overly strict.
Thus, I got rid of any code that tries to validate the config - let's
let the debug adapter itself
decide whether it can digest the configuration or not. validate_config
is now left unimplemented for most
DebugAdapter implementations (except for PHP), because all adapters use
`request`: 'launch'/'attach' for that.
Let's leave the trait method in place though, as nothing guarantees this
to be true for all adapters.

cc @Anthony-Eid

Release Notes:

- debugger: Improved error messages when the debug scenario is not
valid.
- debugger: Fixed cases where valid configs were rejected.
2025-05-30 23:08:41 +02:00
Kirill Bulatov
1e83022f03
Add a JS/TS debug locator (#31769)
With this, a semi-working debug session is possible from the JS/TS
gutter tasks:


https://github.com/user-attachments/assets/8db6ed29-b44a-4314-ae8b-a8213291bffc

For now, available in debug builds only as a base to improve on later on
the DAP front.

Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <peterosiewicz@gmail.com>
2025-05-30 17:15:42 +00:00
Piotr Osiewicz
5462e199fb
debugger: Fix wrong path to the downloaded delve-shim-dap (#31738)
Closes #ISSUE

Release Notes:

- N/A
2025-05-30 10:43:29 +00:00
Piotr Osiewicz
3a60420b41
debugger: Fix delve-dap-shim path on Windows (#31735)
Closes #ISSUE

Release Notes:

- debugger: Fixed wrong path being picked up for delve on Windows
- debugger: Fixed delve not respecting the user-provided binary path
from settings.
2025-05-30 08:53:19 +00:00
Anthony Eid
804de3316e
debugger: Update docs with more examples (#31597)
This PR also shows more completion items when defining a debug config in
a `debug.json` file. Mainly when using a pre build task argument.

### Follow ups
- Add docs for Go, JS, PHP
- Add attach docs

Release Notes:

- debugger beta: Show build task completions when editing a debug.json
configuration with a pre build task
- debugger beta: Add Python and Native Code debug config
[examples](https://zed.dev/docs/debugger)
2025-05-30 04:22:16 +03:00
Piotr Osiewicz
070eac28e3
go: Use delve-dap-shim for spawning delve (#31700)
This allows us to support terminal with go sessions

Closes #ISSUE

Release Notes:

- debugger: Add support for terminal when debugging Go programs
2025-05-29 21:19:56 +02:00
Remco Smits
00bc154c46
debugger: Fix invalid schema for pathMappings (#31595)
See
https://github.com/xdebug/vscode-php-debug?tab=readme-ov-file#remote-host-debugging

Release Notes:

- Debugger Beta: Fixed invalid schema for `pathMappings`
2025-05-28 15:16:12 +00:00
Alex
94a5fe265d
debugger: Improve Go support (#31559)
Supersedes https://github.com/zed-industries/zed/pull/31345 
This PR does not have any terminal/console related stuff so that it can
be solved separately.

Introduces inline hints in debugger:
<img width="1141" alt="image"
src="https://github.com/user-attachments/assets/b0575f1e-ddf8-41fe-8958-2da6d4974912"
/>
Adds locators for go, so that you can your app in debug mode:
<img width="706" alt="image"
src="https://github.com/user-attachments/assets/df29bba5-8264-4bea-976f-686c32a5605b"
/>
As well is allows you to specify an existing compiled binary:
<img width="604" alt="image"
src="https://github.com/user-attachments/assets/548f2ab5-88c1-41fb-af84-115a19e685ea"
/>

Release Notes:

- Added inline value hints for Go debugging, displaying variable values
directly in the editor during debug sessions
- Added Go debug locator support, enabling debugging of Go applications
through task templates
- Improved Go debug adapter to support both source debugging (mode:
"debug") and binary execution (mode: "exec") based on program path

cc @osiewicz, @Anthony-Eid
2025-05-28 12:59:05 +02:00
Anthony Eid
b63cea1f17
debugger beta: Fix gdb/delve JSON data conversion from New Session Modal (#31501)
test that check's that each conversion works properly based on the
adapter's config validation function. 

Co-authored-by: Zed AI \<ai@zed.dev\>

Release Notes:

- debugger beta: Fix bug where Go/GDB configuration's wouldn't work from
NewSessionModal
2025-05-27 17:28:41 +00:00
Anthony Eid
3ff62ef289
debugger beta: Update Javascript's DAP to allow passing in url instead of program (#31494)
Closes #31375

Release Notes:

- debugger beta: Allow passing in URL instead of program for Javascript
launch request
2025-05-27 11:02:16 +00:00