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

fix(lsp): include all diagnosable documents on initialize #17979

Merged
merged 37 commits into from
Mar 30, 2023

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Feb 28, 2023

Copy link
Collaborator

@aapoalas aapoalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed halfway. Left some nitpicks. This is a very anticipated feature! eg. I just ran into this with a repo of some hundreds of files where keeping open (or forgetting to close) all files was just not a possible thing.

cli/lsp/config.rs Outdated Show resolved Hide resolved
cli/lsp/documents.rs Outdated Show resolved Hide resolved
cli/lsp/documents.rs Outdated Show resolved Hide resolved
cli/lsp/documents.rs Outdated Show resolved Hide resolved
cli/lsp/documents.rs Outdated Show resolved Hide resolved
cli/lsp/config.rs Outdated Show resolved Hide resolved
@dsherret dsherret marked this pull request as ready for review March 30, 2023 18:17
@dsherret dsherret marked this pull request as draft March 30, 2023 18:27
@dsherret dsherret marked this pull request as ready for review March 30, 2023 19:15
@@ -42,7 +41,7 @@ fn base_url_to_filename(url: &Url) -> Option<PathBuf> {
}
"data" | "blob" => (),
scheme => {
error!("Don't know how to create cache name for scheme: {}", scheme);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now this error is more likely to happen because it might load in some random files that use a different scheme (ex. "ext:" scheme in our case). This could be especially annoying in the repl. I downgraded this to debug because it didn't seem that important to surface at an "error" level.

@@ -131,24 +131,43 @@ fn pty_complete_expression() {

#[test]
fn pty_complete_imports() {
util::with_pty(&["repl", "-A"], |mut console| {
Copy link
Member Author

@dsherret dsherret Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the pty tests to use a temporary cwd by defualt in util::with_pty because otherwise now it will load too many files in that may conflict with things such as completions. Actually, thinking about it more, I should probably do the same for the lsp tests (Edit: Done)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it makes more sense to use temp CWD here and in the LSP tests

use test_util::testdata_path;
use test_util::TestContextBuilder;
use tower_lsp::lsp_types as lsp;

#[test]
fn lsp_startup_shutdown() {
let mut client = LspClientBuilder::new().build();
let context = TestContextBuilder::new().use_temp_cwd().build();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be the default actually and it should opt out of using a temp cwd. I will look into this in a future PR and it would allow me to revert a lot of this.

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, so exciting to have this finally fixed. I'm sure users will be very happy about this change.

Comment on lines +883 to +891
assert_eq!(
config.enabled_root_urls(),
vec![
root_dir1.join("sub_dir").unwrap(),
root_dir1.join("test.ts").unwrap(),
root_dir2.join("other.ts").unwrap(),
root_dir3
]
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice tests

@@ -7216,3 +7216,56 @@ Deno.test({

client.shutdown();
}

#[test]
fn lsp_closed_file_find_references() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@@ -131,24 +131,43 @@ fn pty_complete_expression() {

#[test]
fn pty_complete_imports() {
util::with_pty(&["repl", "-A"], |mut console| {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, it makes more sense to use temp CWD here and in the LSP tests

@sepehrst
Copy link

This seems to have introduced a regression as described in #18538

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