11<script lang="ts" setup>
2- import { storeToRefs } from ' pinia'
3- import { withDefaults , defineProps , computed } from ' vue'
4- import { useSettingsStore } from ' ../../stores/settings'
2+ import { withDefaults , defineProps , computed , type ComputedRef } from ' vue'
3+ import { useIdeLink } from ' ../../lib/helpers/use-ide-link'
54import { HighlightText } from ' ../highlight-text'
65import { IconSvg } from ' ../icon-svg'
76
@@ -27,9 +26,9 @@ const props = withDefaults(defineProps<Props>(), {
2726 originConfig: null
2827})
2928
30- const { codeEditor } = storeToRefs ( useSettingsStore () )
29+ const { buildLink } = useIdeLink ( )
3130
32- const mappedOrigins = computed (() =>
31+ const mappedOrigins: ComputedRef < Record < string , string >> = computed (() =>
3332 Object .entries (props .originConfig || {}).reduce (
3433 (acc , [key , value ]) => {
3534 const fileName = props .originConfig ?.file || ' '
@@ -51,23 +50,21 @@ const mappedOrigins = computed(() =>
5150 )
5251)
5352
54- const editorLink = computed (() => {
53+ const editorLink: ComputedRef < string | undefined > = computed (() => {
5554 if (! props .originConfig ) {
56- return ' '
55+ return undefined
5756 }
5857
5958 const fileName = mappedOrigins .value .file || ' '
60- const line = mappedOrigins .value .line || ' '
59+ const lineStr = mappedOrigins .value .line || ' '
6160
6261 if (! fileName || fileName === ' unknown' ) {
63- return ' '
62+ return undefined
6463 }
6564
66- if (codeEditor .value == ' vscode' ) {
67- return ` vscode://file/${fileName }${line ? ` :${line } ` : ' ' } `
68- }
65+ const line = lineStr ? parseInt (lineStr , 10 ) : undefined
6966
70- return ` ${ codeEditor . value }://open?file=${ fileName }${ line ? ` & line=${ line } ` : ' ' } `
67+ return buildLink ( fileName , line ) || undefined
7168})
7269
7370const isEditorLink = (key : string ) => !! editorLink .value && (key === ' file' || key === ' line' )
0 commit comments