-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: declarations are not picked from new files #33729
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
Thank you for filing a gopls issue! Please take a look at the Troubleshooting section of the gopls Wiki page, and make sure that you have provided all of the relevant information here. |
Thanks for filing this issue! I'm able to reproduce it. I think we will need to re-run packages.Load if we detect a new file has been created, though I'm not sure how we will handle that considering we only see this as a |
@stamblerre I saw in lsp spec there is interface DidChangeWatchedFilesParams {
/**
* The actual file events.
*/
changes: FileEvent[];
}
interface FileEvent {
/**
* The file's URI.
*/
uri: DocumentUri;
/**
* The change type.
*/
type: number;
}
export namespace FileChangeType {
/**
* The file got created.
*/
export const Created = 1;
/**
* The file got changed.
*/
export const Changed = 2;
/**
* The file got deleted.
*/
export const Deleted = 3;
} This make sense as you can remove or add whole folder with bunch of files. |
@stamblerre Hi, could you also add this to v1.0 milestone? Thanks. |
I see there's different behaviour depending on whether modules have been initialized. If I do |
The reason for this is that, when you are outside of Perhaps we can add some more work-arounds in |
Change https://golang.org/cl/202277 mentions this issue: |
CL above tries to solve it by modifying internal/lsp instead of go/packages. |
I've updated the CL to fix this in go/packages |
Thank you! Sent you a comment on the CL. |
Duplicate of #31553 |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
main.go
foo.go
main.go
What did you expect to see?
I expect to get completion for foo inside main.go
What did you see instead?
I do not get completion, instead I get error
undeclared name: foo
Gopls starts to recognise foo only If a do more edits inside foo.go. Also If I delete foo.go in main.go I see no errors.
The text was updated successfully, but these errors were encountered: