Skip to content

Fix openFileInIDE to respect user's preferred editor#2730

Merged
sejas merged 14 commits intotrunkfrom
stu-1387-fix-open-file-in-ide-ipc-function-to-support-user-preferred
Mar 12, 2026
Merged

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

Conversation

@sejas
Copy link
Copy Markdown
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()
  • Improves getUserEditor to fallback to first detected installed editor
  • Tries to open the site folder and the file in a single system call, with the exception of PhpStorm on Mac, in that case it opens the single file.
  • 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

Test on Mac

open-file-editor-mac.mov

Test on Windows

open-file-IDE.mp4

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
Copy Markdown
Collaborator

wpmobilebot commented Mar 9, 2026

📊 Performance Test Results

Comparing 2157bdd vs trunk

site-editor

Metric trunk 2157bdd Diff Change
load 1779.00 ms 1735.00 ms -44.00 ms ⚪ 0.0%

site-startup

Metric trunk 2157bdd Diff Change
siteCreation 7132.00 ms 6139.00 ms -993.00 ms 🟢 -13.9%
siteStartup 3923.00 ms 3953.00 ms +30.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.
Copy link
Copy Markdown
Contributor

@epeicher epeicher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sejas, for solving this! I have tested it, and it works perfectly on Mac. I have tested with VSCode, Cursor, Zed, and PhpStorm, and it opens fine on all of them. On my version of PhpStorm it does not open the folder, but I don't think that's an issue.

On Windows also works fine, but I have identified that VSCode and Cursor open the folder, and when closing them, they open again with only the file. I have recorded a video with that:

CleanShot.2026-03-10.at.09.29.24.mp4

I like the behaviour of opening the file in the proper folder, which works on Mac, but on Windows, it is confusing. Maybe we can add a condition and open the folder only for Mac? What do you think?

Copy link
Copy Markdown
Contributor

@katinthehatsite katinthehatsite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On macOS, the changes worked as expected for me and I did not see any further regressions. I think we should address Roberto's comments before moving forward 👀

Copy link
Copy Markdown
Contributor

@nightnei nightnei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and works as expected 👍
Left only oen comment about adjusting getFirstInstalledEditor

Comment thread apps/studio/src/ipc-handlers.ts Outdated
@sejas sejas merged commit a403168 into trunk Mar 12, 2026
11 checks passed
@sejas sejas deleted the stu-1387-fix-open-file-in-ide-ipc-function-to-support-user-preferred branch March 12, 2026 09:40
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.

5 participants