diff --git a/packages/react-devtools-shared/src/constants.js b/packages/react-devtools-shared/src/constants.js index 5c2454a36f909..716dad8c575db 100644 --- a/packages/react-devtools-shared/src/constants.js +++ b/packages/react-devtools-shared/src/constants.js @@ -39,6 +39,9 @@ export const SESSION_STORAGE_LAST_SELECTION_KEY = export const LOCAL_STORAGE_OPEN_IN_EDITOR_URL = 'React::DevTools::openInEditorUrl'; +export const LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET = + 'React::DevTools::openInEditorUrlPreset'; + export const LOCAL_STORAGE_PARSE_HOOK_NAMES_KEY = 'React::DevTools::parseHookNames'; diff --git a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js index 8d5f02c1a02f0..eca9f80f2bb32 100644 --- a/packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js +++ b/packages/react-devtools-shared/src/devtools/views/Components/InspectedElement.js @@ -219,8 +219,11 @@ export default function InspectedElementWrapper(_: Props): React.Node { } const url = new URL(editorURL); - url.href = url.href.replace('{path}', source.fileName); - url.href = url.href.replace('{line}', String(source.lineNumber)); + url.href = url.href + .replace('{path}', source.fileName) + .replace('{line}', String(source.lineNumber)) + .replace('%7Bpath%7D', source.fileName) + .replace('%7Bline%7D', String(source.lineNumber)); window.open(url); }, [inspectedElement, editorURL]); diff --git a/packages/react-devtools-shared/src/devtools/views/Settings/ComponentsSettings.js b/packages/react-devtools-shared/src/devtools/views/Settings/ComponentsSettings.js index 023116060e62a..492478b0f058d 100644 --- a/packages/react-devtools-shared/src/devtools/views/Settings/ComponentsSettings.js +++ b/packages/react-devtools-shared/src/devtools/views/Settings/ComponentsSettings.js @@ -16,7 +16,10 @@ import { useRef, useState, } from 'react'; -import {LOCAL_STORAGE_OPEN_IN_EDITOR_URL} from '../../../constants'; +import { + LOCAL_STORAGE_OPEN_IN_EDITOR_URL, + LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET, +} from '../../../constants'; import {useLocalStorage, useSubscription} from '../hooks'; import {StoreContext} from '../context'; import Button from '../Button'; @@ -51,6 +54,8 @@ import type { RegExpComponentFilter, } from 'react-devtools-shared/src/types'; +const vscodeFilepath = 'vscode://file/{path}:{line}'; + export default function ComponentsSettings(_: {}): React.Node { const store = useContext(StoreContext); const {parseHookNames, setParseHookNames} = useContext(SettingsContext); @@ -83,6 +88,10 @@ export default function ComponentsSettings(_: {}): React.Node { [setParseHookNames], ); + const [openInEditorURLPreset, setOpenInEditorURLPreset] = useLocalStorage< + 'vscode' | 'custom', + >(LOCAL_STORAGE_OPEN_IN_EDITOR_URL_PRESET, 'custom'); + const [openInEditorURL, setOpenInEditorURL] = useLocalStorage( LOCAL_STORAGE_OPEN_IN_EDITOR_URL, getDefaultOpenInEditorURL(), @@ -280,15 +289,32 @@ export default function ComponentsSettings(_: {}): React.Node {
Hide components where...
diff --git a/packages/react-devtools-shared/src/devtools/views/Settings/SettingsShared.css b/packages/react-devtools-shared/src/devtools/views/Settings/SettingsShared.css index de0b8da9e6f0f..c803f611908f4 100644 --- a/packages/react-devtools-shared/src/devtools/views/Settings/SettingsShared.css +++ b/packages/react-devtools-shared/src/devtools/views/Settings/SettingsShared.css @@ -88,6 +88,7 @@ border: 1px solid var(--color-border); border-radius: 0.125rem; padding: 0.125rem; + margin-left: .5rem; } .InvalidRegExp,