feat: support Cursor editor as debug session option #5205
+46
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for selecting the preferred editor (VS Code or Cursor) when opening debug sessions in the Dioxus CLI.
Previously, the CLI always used VS Code (
code) for debug sessions. This change introduces a newpreferred-editorglobal setting that allows users to choose between VS Code and Cursor editors.When debugging, the CLI now uses the configured editor's binary command and URL scheme, enabling users who prefer Cursor to seamlessly debug their Dioxus applications without manually switching editors.
Related to issue #5173
Changes
Added
SupportedEditorenum tosettings.rswithVscodeandCursorvariants.Added
preferred_editorfield toCliSettingsstruct to store the user's editor preference.Added
PreferredEditorvariant to theSettingenum inconfig.rsto support thedx config set preferred-editorcommand.Updated
open_debuggermethod inbuilder.rsto:Read the preferred editor from workspace settings (defaulting to VS Code).
Map the editor selection to the appropriate binary command and URL scheme.
Use the selected editor's binary and URL scheme when opening debug sessions.
Updated telemetry logging in
logging.rsto include thePreferredEditorsetting.Usage
Users can set their preferred editor using:
dx config set preferred-editor cursorOr switch back to VS Code:
dx config set preferred-editor vscodeThe setting is stored globally and applies to all debug sessions until changed.
Implementation details
The implementation follows the existing CLI settings pattern used by other settings like
always-hot-reloadanddisable-telemetry.The
SupportedEditorenum usesclap::ValueEnumfor CLI argument parsing andkebab-caseserialization for TOML storage.The default editor is VS Code to maintain backward compatibility.
The URL scheme (
vscode://orcursor://) and binary command (codeorcursor) are mapped dynamically based on the selected editor.All debug session types (Web, macOS, Windows, Linux, Server, iOS, Android) respect the preferred editor setting.