Skip to content

Offer Xdebug setup for Sublime Text, with its project file kept out of the patch - #791

Open
ryanwelcher wants to merge 6 commits into
trunkfrom
add/758-xdebug-setup-for-sublime-text
Open

ryanwelcher wants to merge 6 commits into
trunkfrom
add/758-xdebug-setup-for-sublime-text

Conversation

@ryanwelcher

Copy link
Copy Markdown
Collaborator

Why

A contributor who uses Sublime Text has no Xdebug setup in the app: the setup menu offers VS Code, Cursor, PhpStorm and Zed only. #758 settled on offering it, with Node.js named as a requirement, since Sublime's Debugger package runs its PHP adapter on Node.

What changes

  • Sublime Text in the setup menu. Choosing it shows a .sublime-project with a debugger_configurations entry for the Debugger package's PHP adapter: the same listener (127.0.0.1:9003) and path mapping as the launch.json, with the project's folder as ".".
  • The file lives in the site's folder, like .vscode/launch.json and .zed/debug.json, and stays out of the patch. A new block in each site's .git/info/exclude covers /*.sublime-project and the /*.sublime-workspace Sublime writes beside it. It is a block of its own because the editor-folders block is written only once (Changed files lists editor folders like .idea, and sometimes far more files than expected #737), so new rules there would never reach existing sites.
  • The dialog gives only this app's part. It says Sublime debugs PHP with the Debugger package, whose PHP adapter needs Node.js, and links to the package's setup guide. Then two steps: save the file as xdebug.sublime-project and open it with Project → Open Project; press play, choose Listen for Xdebug, press play again.
  • Deliberately not in it: installing Package Control or the package, and troubleshooting. That includes the node setting for a Sublime opened from the macOS Dock that cannot find an nvm or Homebrew Node. See Risks.

How to test this

Platforms: any. macOS is where the Node PATH case below shows up. Use the Buildkite artifact for the current head.

Starting state: Sublime Text 4 with Node.js installed, an existing Gutenberg (plugin) site and an existing Core site, both created before this build, and Xdebug turned on in Settings.

  1. Start the Gutenberg site's server. In the server's details, select Set up Xdebug for your editor, then Sublime Text.
    • The dialog names Node.js and links to the Debugger package's setup guide. Selecting the link opens https://github.com/daveleroy/SublimeDebugger in the browser.
    • The project file maps /wordpress/wp-content/plugins/gutenberg to the site's folder.
  2. If the Debugger package is not set up, follow the guide: Package Control, Debugger, then Debugger: Install Adapters → PHP.
  3. Select Copy project file, save it in the site's folder as xdebug.sublime-project, and open it with Project → Open Project.
    • The sidebar shows the site's folder.
  4. Run Debugger: Open, press play, choose Listen for Xdebug, and press play again.
    • The Debugger listens on port 9003.
  5. Set a breakpoint in a PHP file Gutenberg runs on every page load, and load a page of the site.
    • Execution stops on the breakpoint.
  6. Make any edit to a PHP file, and open the site's changes.
    • The patch contains that edit only.
  7. Repeat steps 1, 3 and 6 on the Core site. Its file maps /wordpress to the site's src folder.

What must not have happened:

  • xdebug.sublime-project or xdebug.sublime-workspace in the changed files or the patch, on either site, though both sites were created before this build.
  • On macOS with Node from nvm or Homebrew and Sublime opened from the Dock, step 4 can fail with "This adapter requires node…". That is the known gap below, not a regression. Setting "node" to the output of which node in Preferences: Debugger Settings fixes it.

Covered by tests: the config shape (unit, both path styles and both serve strategies), the exclude on a site created before this change (ipc-wiring, red without the new block), and the menu, dialog text, link and file contents (the xdebug.spec.js journey). A real Sublime connecting to Xdebug was tested by hand on macOS only.

Risks and limitations

  • The Node PATH fix on macOS is left to the user. The self-review flagged this (1 finding, deferred by decision): Sublime opened from the Dock does not get the shell's PATH, so an nvm or Homebrew Node is "not found", and the Debugger's error points to nodejs.org. Neither the package's README nor this dialog mentions the node setting that fixes it. This was a deliberate call to keep troubleshooting a third-party package out of the app; it changes what the Offer Xdebug setup for Sublime Text #758 comment asked for.
  • The setup guide is a third-party GitHub README, which can move or change.
  • New strings are not translated yet.

Related

Fixes #758. Follows #723 and #767.


Design decisions and alternatives considered
  • Project file outside the site's folder, with an absolute folder path. This was the first version. It needed no exclude rule, but it put Sublime's file somewhere different from every other editor's, and left the user to pick and remember a place for it.
  • Adding the rules to the editor-folders block. Rejected: that block is written once, so existing sites would never get them (the Changed files lists editor folders like .idea, and sometimes far more files than expected #737 problem).
  • A full walkthrough in the dialog (Package Control, Debugger, PHP adapter, Node, the node setting). Built first, then cut. Testing it by hand showed it turning into troubleshooting for a third-party package.
  • A file named only .sublime-project. An earlier wording invited it. macOS hides a file whose name starts with a dot, so Open Project cannot choose it. The dialog now gives a full name.
  • Detecting Node from the app. Rejected in Offer Xdebug setup for Sublime Text #758: the app sees a different PATH from a Sublime opened from the Dock, and a wrong "Node found" is worse than no check.
Review outcome (required — see AGENTS.md)

1 [fix here] · 0 [follow-up]: deferred by decision (see Risks).

  • Review: completed. Reviewed by a fresh agent context against .github/instructions/code-review.instructions.md. Reviewed head da6c589 / base 60e9d96 (origin/trunk). npm run lint clean; npm test 2315 pass, 0 fail, 9 skipped; the xdebug.spec.js journey 5/5, run hidden.
    • 🟡 Cross-platform, xdebug-setup-dialog.jsx: no mention of the node setting for a Sublime opened from the macOS Dock. Deferred: the app does not troubleshoot the Debugger package.
    • Verified clean: the exclude rules match the file and its workspace; existing sites get the block through site:status before the dialog can open; "." with absolute Windows pathMappings; the link goes through url:open and its allow-list; no branching logic in the .jsx.
    • Style notes not acted on: docs/guide/editors.md and the src/exclude-file.cjs header do not list the new block; ensureLocalExcludes's @return wording (no caller reads it).
  • Since review: da6c589 → c7c9f4e checked. It changes only a code comment, which wrongly said the package's README covers what to do when setup fails.
  • CodeRabbit: not requested yet.
Screenshots or recording

To add: the Sublime Text setup dialog.

🤖 Generated with Claude Code

Sublime Text's Debugger package runs the same Xdebug adapter as VS Code,
configured in a .sublime-project. The setup gives a whole project file,
naming the site's folder by its full path so it can be saved outside the
checkout, and its first step says Node.js is required, with the node
setting as the fix when Sublime opened from the Dock cannot find it.

Fixes #758.
…s macOS's

Preferences: Debugger Settings is a command palette entry the Debugger
package adds, not an item in Sublime's Preferences menu, and exists only
once the package is installed. which node does not exist on Windows,
where restarting Sublime after installing Node is the fix. Also adds
Sublime Text to the README's list of editors.
A fresh Sublime Text has no Package Control, so Package Control: Install
Package is not in the command palette. Sublime Text 4's own Install
Package Control command adds it.
The Xdebug setup asked for the .sublime-project to be saved outside the
site's folder. It now goes in the site's folder, like VS Code's and Zed's
files, and opens it as '.'. A block of its own in .git/info/exclude keeps
*.sublime-project and the .sublime-workspace Sublime writes beside it out
of a patch, so sites seeded before this get it too.
The Sublime Text Xdebug setup walked through installing Package Control,
the Debugger package, its PHP adapter and Node.js, and how to fix Node not
being found. That is the package's to explain, so the dialog now says what
the package needs, links to its setup guide, and keeps only this site's
project file and how to start it.

The file now has a name, xdebug.sublime-project, since a file named only
.sublime-project is hidden on macOS and Open Project cannot choose it. The
last step says to choose Listen for Xdebug when play asks, since the
Debugger selects no configuration by itself.
…ately

The comment said the package's README covers what to do when its setup
fails. It does not cover the node setting that fixes a Sublime opened
from the Dock not finding Node, which the dialog leaves out on purpose.
@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offer Xdebug setup for Sublime Text

1 participant