Skip to content

Commit

Permalink
Merge branch 'main' into add-remix
Browse files Browse the repository at this point in the history
  • Loading branch information
ericclemmons authored Nov 25, 2023
2 parents 6501b7b + b56ca31 commit d62564c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions packages/click-to-react-component/src/ClickToComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}

Expand Down
13 changes: 13 additions & 0 deletions packages/click-to-react-component/src/getUrl.js
Original file line number Diff line number Diff line change
@@ -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}`
}

0 comments on commit d62564c

Please sign in to comment.