Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In mounted, ctrl-click on method invocation not jumping to definition #3985

Open
yubaoquan opened this issue Mar 5, 2024 · 3 comments
Open
Labels
vue2 Issues that concern vue2

Comments

@yubaoquan
Copy link

<template>
  <div>test</div>
</template>

<script>
export default {
  name: 'my-test',
  mounted() {
    this.foo() // ctrl-click on foo, not working
  },
  methods: {
    foo() {
      console.info(`hello`)
    },
    bar() {
      this.foo() // ctrl-click on foo, jump to definition
    },
  },
}
</script>

<style lang="less" scoped></style>

jsconfig.json

{
  "vueCompilerOptions": {
    "target": 2
  }
}

version:
vue: 2.6.11
@vue/runtime-dom: ^3.4.21

@rafalglowacz
Copy link

rafalglowacz commented Mar 18, 2024

I have a similar issue, except with Vue 2.7 and jumping from a method to another method's definition also doesn't work, unlike in OP's case.

I've created a simple repro repo by running npm create vue@^2 and then making the following changes:

https://github.com/rafalglowacz/vue2-project-no-ts/compare/3cfb986a35c760a88adbf8c957674cc187283903..053425657a46debebdb54c1cf90399264081338d

I haven't installed @vue/runtime-dom as I have Vue 2.7 and according to the setup docs it's not needed. I mean, I did try it for good measure, but unsurprisingly it didn't change anything 😁

@so1ve
Copy link
Member

so1ve commented Mar 19, 2024

For vue 2.6 you should use vetur.

@rafalglowacz
Copy link

rafalglowacz commented Mar 30, 2024

What about 2.7, is it expected to work when defining components with export default {...}? I'm trying to investigate it but I'm new to language servers, it might take a while.

I started by checking the vue-language-server process with Chromium debugger and didn't find anything there.

Now I'm doing the same with typescript-language-server and I'm currently in this file:

.../vue-language-server/node_modules/@vue/language-server/node_modules/@volar/typescript/lib/node/decorateLanguageService.js

It's in the Volar directory, but it comes up when debugging TS language server because this file uses it:

.../typescript-language-server/node_modules/typescript/lib/tsserver.js

It calls getDefinitionAndBoundSpan() which then calls linkedCodeFeatureWorker(), that's what I'm stepping through now, maybe I'll get to the bottom of this. Anything you can advise?

EDIT: the workaround from #4996 fixed the issue for me.

@davidmatter davidmatter added the vue2 Issues that concern vue2 label Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
vue2 Issues that concern vue2
Projects
None yet
Development

No branches or pull requests

4 participants