Skip to content

Commit 0abd9d9

Browse files
committed
fix usage & lint
1 parent 2f5fc91 commit 0abd9d9

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/packageJsonLinks.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import * as vscode from 'vscode'
12
import { parseTree, findNodeAtLocation, getNodeValue, Node } from 'jsonc-parser'
23
import { compact } from 'lodash'
3-
import * as vscode from 'vscode'
44
import { getExtensionSetting, getExtensionCommandId } from 'vscode-framework'
55
import { packageJsonSelector } from './packageJsonComplete'
66

@@ -29,15 +29,16 @@ export const registerPackageJsonLinks = () => {
2929
const targetScriptNode = scriptsNodes.find(node => node.children![0]!.value === scriptRefName)?.children?.[1]
3030
if (!targetScriptNode) continue
3131
const getNodeStringStart = (node: Node) => node.offset + 1
32-
const startOffset = getNodeStringStart(scriptNode) + match.index + match[1]!.length
33-
const positions = [startOffset, startOffset + scriptRefName.length].map(offset => document.positionAt(offset)) as [
32+
let startOffset = getNodeStringStart(scriptNode) + match.index + match[1]!.length
33+
if (match[0]!.startsWith('"')) startOffset += 1
34+
const { line: targetScriptLine, character: targetScriptCharacter } = document.positionAt(getNodeStringStart(targetScriptNode))
35+
const fragment = `L${targetScriptLine + 1},${targetScriptCharacter + 1}`
36+
const linkPositions = [startOffset, startOffset + scriptRefName.length].map(offset => document.positionAt(offset)) as [
3437
vscode.Position,
3538
vscode.Position,
3639
]
37-
const { line: targetScriptLine, character: targetScriptCharacter } = document.positionAt(getNodeStringStart(targetScriptNode))
38-
const fragment = `L${targetScriptLine + 1},${targetScriptCharacter + 1}`
3940
links.push({
40-
range: new vscode.Range(...positions),
41+
range: new vscode.Range(...linkPositions),
4142
tooltip: 'Reveal script',
4243
target: document.uri.with({ fragment }),
4344
})

0 commit comments

Comments
 (0)