Skip to content

Commit 48e1e0f

Browse files
authored
feat: support custom file go to difinition (#102)
1 parent a1a3fe1 commit 48e1e0f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/monaco/Monaco.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,22 @@ onMounted(async () => {
105105
})
106106
editor.value = editorInstance
107107
108+
// Support for go to definition
109+
monaco.editor.registerEditorOpener({
110+
openCodeEditor(_, resource) {
111+
const path = resource.path
112+
if (/^\//.test(path) && !/^\/node_modules/.test(path)) {
113+
const fileName = path.replace('/', '')
114+
if (fileName !== store.state.activeFile.filename) {
115+
store.setActive(fileName)
116+
return true
117+
}
118+
}
119+
120+
return false
121+
}
122+
})
123+
108124
// Support for semantic highlighting
109125
const t = (editorInstance as any)._themeService._theme
110126
t.getTokenStyleMetadata = (

0 commit comments

Comments
 (0)