-
Notifications
You must be signed in to change notification settings - Fork 1.7k
go-to-definition on an import keyword should open the corresponding file #60524
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
Comments
Navigation currently works for me when I click on the URI. Can you provide more information about what isn't working for you? |
Control click on the url works It would be great if go to definition would work the same. That way I don't need to use the mouse. And it was more intuitive for me (I imagine it would be the same for others) |
Ok, thanks. I think I understand now. It seems a little odd to me to think of a file as being the definition of itself, but I suppose it's not too big a stretch. @DanTup Is this behavior that would be consistent with go to definition? |
I see a path like a function signature and the file content as the function body but I might have a weird mind 🤪 |
I think so - and it should already work. I just tested it and it seems to work for me (for relative paths, gotodef.mp4@stephane-archer can you confirm in what cases this doesn't seem to work for you, and what you see (if anything) when clicking Go to Definition? |
@DanTup it does not work if your cursor is on the “import” keyword |
Oh, I see. It's less clear to me that it should work for the It's less clear the behaviour would be obvious with conditional imports though: import 'src/hw_none.dart'
if (dart.library.io) 'src/hw_io.dart'
if (dart.library.js_interop) 'src/hw_web.dart'; Presumably you'd want the There is some precedence for Go-to-Definition not strictly being a definition, for example you can use it on keywords like I'm probably on the fence about this and would be interested in others opinions. |
That is definitely a convenience. Why would you prefer the go to definition to return nothing here? The user is clearly expected to get an answer when running the command, not "please move your cursor on the path so I can give you the right answer" |
I wouldn't specifically prefer this, but I would prefer that it was obvious what would happen if you do this and I'm not sure if it is in the case of conditional imports (for example might you assume it goes to the import that would resolve for the Dart VM, or whichever Flutter device you have selected in the IDE?). (We might also need to consider whether changing this would affect IntelliJ, as it uses the navigation data a little differently to VS Code, so I don't know if including the import keyword in the range - or producing an additional range for it - would have any consequences) |
I agree, it's completely ambiguous in the case of a conditional import. We don't currently support "Go to Definition" for any keyword, and I think that's reasonable. |
In that case, I think this is working as intended - shall we close this? |
go to the definition on an import statement should open the corresponding file
The text was updated successfully, but these errors were encountered: