Skip to content

Fix openFileInIDE to respect user's preferred editor#2730

Open
sejas wants to merge 6 commits intotrunkfrom
stu-1387-fix-open-file-in-ide-ipc-function-to-support-user-preferred
Open

Fix openFileInIDE to respect user's preferred editor#2730
sejas wants to merge 6 commits intotrunkfrom
stu-1387-fix-open-file-in-ide-ipc-function-to-support-user-preferred

Conversation

@sejas
Copy link
Member

@sejas sejas commented Mar 9, 2026

Related issues

Proposed Changes

The openFileInIDE IPC handler was hardcoded to only check for VS Code and PhpStorm, ignoring the user's preferred editor setting configured in Settings > Preferences.

This PR updates the handler to:

  • Read the user's preferred editor from settings via getUserEditor()
  • Use supportedEditorConfig to get the correct URL scheme for the selected editor
  • Fall back to the first installed editor (in SUPPORTED_EDITORS priority order) when no preference is set
  • Do nothing gracefully if no editor is installed

All 8 supported editors (Antigravity, Cursor, VS Code, PhpStorm, Windsurf, WebStorm, Sublime Text, Zed) now work with the "open file in IDE" feature.

Testing Instructions

Apply this diff to test it:

diff --git a/apps/studio/src/components/content-tab-overview.tsx b/apps/studio/src/components/content-tab-overview.tsx
index 6055a8931..3ca26cbde 100644
--- a/apps/studio/src/components/content-tab-overview.tsx
+++ b/apps/studio/src/components/content-tab-overview.tsx
@@ -9,6 +9,7 @@ import {
 	navigation,
 	page,
 	preformatted,
+	settings,
 	styles,
 	symbolFilled,
 	widget,
@@ -162,6 +163,15 @@ function ShortcutsSection( { selectedSite }: Pick< ContentTabOverviewProps, 'sel
 		} );
 	}
 
+	buttonsArray.push( {
+		label: __( 'wp-config.php' ),
+		className: 'text-nowrap',
+		icon: settings,
+		onClick: () => {
+			getIpcApi().openFileInIDE( 'wp-config.php', selectedSite.id );
+		},
+	} );
+
 	const terminalName = getTerminalName( terminal );
 	buttonsArray.push( {
 		label: terminalName,
  1. Start the app with npm start
  2. Open Settings > Preferences and select a preferred editor (e.g., Cursor, Sublime Text)
  3. Open the AI assistant, ask it to create/edit a file
  4. Click the file path in the assistant response
  5. Verify the file opens in your selected editor, not just VS Code/PhpStorm
  6. Change the preferred editor and repeat — it should respect the new selection
  7. Remove the preferred editor setting and verify it falls back to the first installed editor

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors? (Tests pass, no errors)

sejas added 2 commits March 9, 2026 17:55
The IPC handler was hardcoded to only check for VS Code and PhpStorm,
ignoring the user's preferred editor preference. Now reads the preferred
editor from user settings and falls back to the first installed editor
from the supported editors list.
Tests cover: preferred editor usage, fallback to first installed editor,
no editor available, site not found, file not found, priority order,
and site-folder-first opening sequence.
@sejas sejas self-assigned this Mar 9, 2026
@sejas sejas requested a review from a team March 9, 2026 22:20
@sejas sejas marked this pull request as ready for review March 9, 2026 22:20
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Mar 9, 2026

📊 Performance Test Results

Comparing 79ab184 vs trunk

site-editor

Metric trunk 79ab184 Diff Change
load 1442.00 ms 1779.00 ms +337.00 ms 🔴 23.4%

site-startup

Metric trunk 79ab184 Diff Change
siteCreation 6092.00 ms 6081.00 ms -11.00 ms ⚪ 0.0%
siteStartup 3938.00 ms 3942.00 ms +4.00 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Use path.join() for file path assertions and mock winFindEditorPath
so exec is called on Windows instead of falling back to shell.openExternal.
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.

2 participants