diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 13e4087..579d0c9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,25 +13,25 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits fetch-depth: 0 - name: Setup Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v3 with: node-version: lts/* - name: Cache pnpm modules - uses: actions/cache@v2 + uses: actions/cache@v3 with: path: ~/.pnpm-store key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} restore-keys: | ${{ runner.os }}- - - uses: pnpm/action-setup@v2.1.0 + - uses: pnpm/action-setup@v2 with: run_install: true version: latest diff --git a/packages/click-to-react-component/src/ClickToComponent.js b/packages/click-to-react-component/src/ClickToComponent.js index f5a04c0..7ed3ea5 100644 --- a/packages/click-to-react-component/src/ClickToComponent.js +++ b/packages/click-to-react-component/src/ClickToComponent.js @@ -10,6 +10,7 @@ import * as React from 'react' import { ContextMenu } from './ContextMenu.js' import { getPathToSource } from './getPathToSource.js' import { getSourceForElement } from './getSourceForElement.js' +import { getUrl } from './getUrl.js' export const State = /** @type {const} */ ({ IDLE: 'IDLE', @@ -41,8 +42,10 @@ export function ClickToComponent({ editor = 'vscode', pathModifier }) { if (state === State.HOVER && target instanceof HTMLElement) { const source = getSourceForElement(target) const path = getPathToSource(source, pathModifier) - - const url = `${editor}://file/${path}` + const url = getUrl({ + editor, + pathToSource: path, + }) event.preventDefault() window.location.assign(url) @@ -56,7 +59,11 @@ export function ClickToComponent({ editor = 'vscode', pathModifier }) { const onClose = React.useCallback( function handleClose(returnValue) { if (returnValue) { - const url = `${editor}://file/${returnValue}` + const url = getUrl({ + editor, + pathToSource: returnValue, + }) + window.location.assign(url) } diff --git a/packages/click-to-react-component/src/getUrl.js b/packages/click-to-react-component/src/getUrl.js new file mode 100644 index 0000000..3b75cba --- /dev/null +++ b/packages/click-to-react-component/src/getUrl.js @@ -0,0 +1,13 @@ +/** + * @param {Object} param + * @param {string} param.editor + * @param {string} param.pathToSource + */ +export function getUrl({ editor, pathToSource }) { + // Fix https://github.com/microsoft/vscode/issues/197319 + if (pathToSource[0] === '/') { + return `${editor}://file${pathToSource}` + } + + return `${editor}://file/${pathToSource}` +}