diff --git a/extension/src/browser/extension/options/EditorGroup.tsx b/extension/src/browser/extension/options/EditorGroup.tsx
index 130ef824..dd981e10 100644
--- a/extension/src/browser/extension/options/EditorGroup.tsx
+++ b/extension/src/browser/extension/options/EditorGroup.tsx
@@ -47,37 +47,12 @@ export default ({ options, saveOption }: OptionsProps) => {
id="editor"
type="text"
size={33}
- maxLength={30}
- placeholder="vscode, atom, webstorm, sublime..."
- value={options.editor}
+ placeholder={'vscode://file/{path}:{line}:{column}'}
+ value={options.editorURL}
disabled={options.useEditor !== EditorState.EXTERNAL}
- onChange={(e) =>
- saveOption('editor', e.target.value.replace(/\W/g, ''))
- }
+ onChange={(e) => saveOption('editorURL', e.target.value)}
/>
-
-
-
-
);
};
diff --git a/extension/src/browser/extension/options/syncOptions.ts b/extension/src/browser/extension/options/syncOptions.ts
index ede4b150..7fe90340 100644
--- a/extension/src/browser/extension/options/syncOptions.ts
+++ b/extension/src/browser/extension/options/syncOptions.ts
@@ -2,8 +2,7 @@ import { FilterState, FilterStateValue } from '../../../app/api/filters';
export interface Options {
readonly useEditor: number;
- readonly editor: string;
- readonly projectPath: string;
+ readonly editorURL: string;
readonly maxAge: number;
readonly filter: FilterStateValue;
readonly allowlist: string;
@@ -16,8 +15,7 @@ export interface Options {
interface OldOrNewOptions {
readonly useEditor: number;
- readonly editor: string;
- readonly projectPath: string;
+ readonly editorURL: string;
readonly maxAge: number;
readonly filter:
| FilterStateValue
@@ -77,8 +75,7 @@ const get = (callback: (options: Options) => void) => {
chrome.storage.sync.get(
{
useEditor: 0,
- editor: '',
- projectPath: '',
+ editorURL: '',
maxAge: 50,
filter: FilterState.DO_NOT_FILTER,
whitelist: '',
diff --git a/packages/redux-devtools-inspector-monitor-trace-tab/src/openFile.ts b/packages/redux-devtools-inspector-monitor-trace-tab/src/openFile.ts
index 2d8fd7ec..6a632a51 100644
--- a/packages/redux-devtools-inspector-monitor-trace-tab/src/openFile.ts
+++ b/packages/redux-devtools-inspector-monitor-trace-tab/src/openFile.ts
@@ -55,8 +55,7 @@ function openInIframe(url: string) {
setTimeout(() => iframe.parentNode!.removeChild(iframe), 3000);
}
-function openInEditor(editor: string, path: string, stackFrame: StackFrame) {
- const projectPath = path.replace(/\/$/, '');
+function openInEditor(editorURL: string, stackFrame: StackFrame) {
const file =
stackFrame._originalFileName ||
(stackFrame as unknown as { finalFileName: string }).finalFileName ||
@@ -69,30 +68,17 @@ function openInEditor(editor: string, path: string, stackFrame: StackFrame) {
const line = stackFrame._originalLineNumber || stackFrame.lineNumber || '0';
const column =
stackFrame._originalColumnNumber || stackFrame.columnNumber || '0';
- let url;
- switch (editor) {
- case 'vscode':
- case 'code':
- url = `vscode://file/${projectPath}${filePath}:${line}:${column}`;
- break;
- case 'atom':
- url = `atom://core/open/file?filename=${projectPath}${filePath}&line=${line}&column=${column}`;
- break;
- case 'webstorm':
- case 'phpstorm':
- case 'idea':
- url = `${editor}://open?file=${projectPath}${filePath}&line=${line}&column=${column}`;
- break;
- default:
- // sublime, emacs, macvim, textmate + custom like https://github.com/eclemens/atom-url-handler
- url = `${editor}://open/?url=file://${projectPath}${filePath}&line=${line}&column=${column}`;
- }
+ const url = new URL(editorURL);
+ url.href = url.href.replace('{path}', filePath);
+ url.href = url.href.replace('{line}', String(line));
+ url.href = url.href.replace('{column}', String(column));
+
if (chrome.devtools && !isFF) {
- if (chrome.tabs) openAndCloseTab(url);
+ if (chrome.tabs) openAndCloseTab(url.href);
else window.open(url);
} else {
- openInIframe(url);
+ openInIframe(url.href);
}
}
@@ -105,37 +91,29 @@ export default function openFile(
const storage = isFF
? chrome.storage.local
: chrome.storage.sync || chrome.storage.local;
- storage.get(
- ['useEditor', 'editor', 'projectPath'],
- function ({ useEditor, editor, projectPath }) {
+ storage.get(['useEditor', 'editorURL'], function ({ useEditor, editorURL }) {
+ if (useEditor && typeof editorURL === 'string') {
+ openInEditor(editorURL, stackFrame);
+ } else {
if (
- useEditor &&
- projectPath &&
- typeof editor === 'string' &&
- /^\w{1,30}$/.test(editor)
+ chrome.devtools &&
+ chrome.devtools.panels &&
+ !!chrome.devtools.panels.openResource
) {
- openInEditor(editor.toLowerCase(), projectPath as string, stackFrame);
- } else {
- if (
- chrome.devtools &&
- chrome.devtools.panels &&
- !!chrome.devtools.panels.openResource
- ) {
- openResource(fileName, lineNumber, stackFrame);
- } else if (chrome.runtime && (chrome.runtime.openOptionsPage || isFF)) {
- if (chrome.devtools && isFF) {
- chrome.devtools.inspectedWindow.eval(
- 'confirm("Set the editor to open the file in?")',
- (result) => {
- if (!result) return;
- chrome.runtime.sendMessage({ type: 'OPEN_OPTIONS' });
- }
- );
- } else if (confirm('Set the editor to open the file in?')) {
- chrome.runtime.openOptionsPage();
- }
+ openResource(fileName, lineNumber, stackFrame);
+ } else if (chrome.runtime && (chrome.runtime.openOptionsPage || isFF)) {
+ if (chrome.devtools && isFF) {
+ chrome.devtools.inspectedWindow.eval(
+ 'confirm("Set the editor to open the file in?")',
+ (result) => {
+ if (!result) return;
+ chrome.runtime.sendMessage({ type: 'OPEN_OPTIONS' });
+ }
+ );
+ } else if (confirm('Set the editor to open the file in?')) {
+ chrome.runtime.openOptionsPage();
}
}
}
- );
+ });
}