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

Can not jump to definition when current opened buffer was belong to a package. (but VSCode can) #152

Closed
zw963 opened this issue Mar 16, 2022 · 10 comments

Comments

@zw963
Copy link

zw963 commented Mar 16, 2022

this issue just copy from here

i fork flutter_sample project here, you can try reproduce on test_jump_to_definition branch.

Following is reproduce:

  1. switch to test_jump_to_definition branch
  2. open lib/main.dart, hover on Dashboard, as screenshot.
    image
  3. try jump to definition. (xref-find-definitions), it jump to lib/screens/dashboard/dashboard.dart, it works!
  4. hover on DesktopMultiWindow, try jump to def, it jump to ~/.pub-cache/hosted/pub.flutter-io.cn/desktop_multi_window-0.0.1/lib/desktop_multi_window.dart:11, it still works!
  5. at this time, lsp give me a selection. like following screenshot.
    image
    I select to set root directory interactively, that is, ~/.pub-cache/hosted/pub.flutter-io.cn/desktop_multi_window-0.0.1, i consider this is the correct option, right? please point out if this is not intended. from my point, if not set lsp root, there is no way to continue jump to next definition.
  6. hover on multiWindowChannel, jump to definition, it goto ~/.pub-cache/hosted/pub.flutter-io.cn/desktop_multi_window-0.0.1/lib/src/channels.dart, it seem like sitll works, though, as you can see, many flycheck error on this file.

image

  1. now my issue is coming. when hover on MethodChannel, it can't jump to definition. (but can when use VSCode)
    image

@ericdallo
Copy link
Member

I can't repro this, but what I do is press n when lsp-mode asks about import that new package and works

@zw963
Copy link
Author

zw963 commented Jun 12, 2022

In fact, this issue same as #146 , those error not displayed if pressing n to not treat package root as LSP root, but it not jumpable as VSCode does.

as you mention in #128 (comment), VSCode must do some magic things which make jump to definition always happen even in package, maybe lsp-dart will work someday.

@ericdallo
Copy link
Member

it does work for me with lsp-dart jumping to multiple packages, it could be some corner case we are not aware of yet

@zw963
Copy link
Author

zw963 commented Jun 14, 2022

it does work for me with lsp-dart jumping to multiple packages, it could be some corner case we are not aware of yet

Yes, it can jumping to packages, but, then, ipressing n when tips add package folder into lsp, then, when try do jump in package, it not works.

@ericdallo
Copy link
Member

Yeah, I need to repro to understand why it happens, can you repro on the flutter sample repo?

@zw963
Copy link
Author

zw963 commented Jun 14, 2022

Yeah, I need to repro to understand why it happens, can you repro on the flutter sample repo?

No, it seem like in flutter_sample repo, there is no dart code use external package, so, there is no way to jump out to package?

@ericdallo
Copy link
Member

Hum, I thought jumping to flutter internal is considered a external package

@zw963
Copy link
Author

zw963 commented Jun 15, 2022

Hum, I thought jumping to flutter internal is considered a external package

Sure no, haha, let us leave this issue for a moment, if i meet same issue again, i will do some research, and report here ASAP.

@ericdallo
Copy link
Member

@zw963 I made a commit which should fix this: a8939d6
LMK if otherwise

@zw963
Copy link
Author

zw963 commented Oct 31, 2022

Cool, thanks, that will be a big improvement, i am not use dart recent days, i will test it later and give feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants