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

Allow recent created files to be imported #12

Closed
ericdallo opened this issue Apr 3, 2020 · 10 comments
Closed

Allow recent created files to be imported #12

ericdallo opened this issue Apr 3, 2020 · 10 comments

Comments

@ericdallo
Copy link
Member

Describe the bug
when using lsp-mode with dart-mode, after I create a new dart file, when I try to use it, it just don't show an option on lsp-ui for the auto import.
Sometimes if I run lsp-restart-workspace then lsp again, or I kill the buffer, the option to import shows off.

To Reproduce
Example:

I create a file b.dart:

class B {

}

then on an existent file a.dart, lsp-ui doesn't recognize the class to import:

void main() {
    final b = B();
}

the only options are:
image

Expected behavior
Like lsp-java I expect it to recognize the new file/class and allows me to import it.

Which Language Server did you use
lsp-dart

OS
Which os do you use?
NixOS 20.03

Error callstack

@itome
Copy link

itome commented Apr 7, 2020

I'm seeing same issue, and when I checked this in VSCode it works fine.
But lsp-mode with typescript-language-server also works fine with recent created files.

@yyoncho
Copy link
Member

yyoncho commented Apr 7, 2020

Not sure if it is the same issue but in the past I have investigated similar issue. It was caused by the fact that emacs creates files in memory while vscode touches them on the disk. Can you try touch file.foo from the command line and then opening it in emacs? If it works - the issue is on the server.

@itome
Copy link

itome commented Apr 9, 2020

It seems that auto import is not working even with file that is create by touch command.

@ericdallo
Copy link
Member Author

ericdallo commented Apr 9, 2020

I was able to confirm that the problem is on server.

$ touch b.dart
$ echo 'class B { }' > b.dart

Then in a.dart, it shows an option to import b.dart

@yyoncho yyoncho transferred this issue from emacs-lsp/lsp-mode Apr 24, 2020
@ericdallo ericdallo changed the title [dart] - Allow recent created files be imported Allow recent created files to be imported Apr 24, 2020
@ericdallo
Copy link
Member Author

@yyoncho, so do you think I should open an issue on upstream?
It's odd, since creating the file via the terminal as I said above, works great. Isn't this a lsp-mode bug?

@yyoncho
Copy link
Member

yyoncho commented Apr 25, 2020

Here it is the spec:

The document open notification is sent from the client to the server to signal newly opened text documents. The document’s content is now managed by the client and the server must not try to read the document’s content using the document’s Uri.

The server should work without depending on the file present on the disc or not.

@ericdallo
Copy link
Member Author

ericdallo commented Apr 25, 2020

It makes totally sense, a weird behavior too, is that evenly saving the buffer before or after creating the B class, it does not work

@DanTup
Copy link

DanTup commented Sep 8, 2020

This might be the same issue shown here:

Dart-Code/Dart-Code#2286 (comment)

Which should be fixed by:

https://dart-review.googlesource.com/c/sdk/+/154960/

@ericdallo
Copy link
Member Author

Thanks, @DanTup, I'll try to reproduce the issue with the fix...

@ericdallo
Copy link
Member Author

I could confirm that this is fixed on the latest SDK: http://gsdview.appspot.com/dart-archive/channels/be/raw/latest/sdk/
Thank you very much @DanTup!

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

No branches or pull requests

4 participants