summaryrefslogtreecommitdiff
path: root/cli/lsp/analysis.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-06-05 11:04:16 -0400
committerGitHub <noreply@github.com>2024-06-05 17:04:16 +0200
commit7ed90a20d04982ae15a52ae2378cbffd4b6839df (patch)
tree3297d6f7227fbf1cf80e17a2a376ef4dfa52e6ad /cli/lsp/analysis.rs
parent0544d60012006b1c7799d8b6eafacec9567901ad (diff)
fix: better handling of npm resolution occurring on workers (#24094)
Closes https://github.com/denoland/deno/issues/24063
Diffstat (limited to 'cli/lsp/analysis.rs')
-rw-r--r--cli/lsp/analysis.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs
index f60f2e044..62feeb602 100644
--- a/cli/lsp/analysis.rs
+++ b/cli/lsp/analysis.rs
@@ -724,8 +724,8 @@ impl CodeActionCollection {
&mut self,
specifier: &ModuleSpecifier,
diagnostic: &lsp::Diagnostic,
- maybe_text_info: Option<SourceTextInfo>,
- maybe_parsed_source: Option<deno_ast::ParsedSource>,
+ maybe_text_info: Option<&SourceTextInfo>,
+ maybe_parsed_source: Option<&deno_ast::ParsedSource>,
) -> Result<(), AnyError> {
if let Some(data_quick_fixes) = diagnostic
.data
@@ -774,8 +774,8 @@ impl CodeActionCollection {
&mut self,
specifier: &ModuleSpecifier,
diagnostic: &lsp::Diagnostic,
- maybe_text_info: Option<SourceTextInfo>,
- maybe_parsed_source: Option<deno_ast::ParsedSource>,
+ maybe_text_info: Option<&SourceTextInfo>,
+ maybe_parsed_source: Option<&deno_ast::ParsedSource>,
) -> Result<(), AnyError> {
let code = diagnostic
.code
@@ -830,7 +830,7 @@ impl CodeActionCollection {
.push(CodeActionKind::DenoLint(ignore_error_action));
// Disable a lint error for the entire file.
- let maybe_ignore_comment = maybe_parsed_source.clone().and_then(|ps| {
+ let maybe_ignore_comment = maybe_parsed_source.and_then(|ps| {
// Note: we can use ps.get_leading_comments() but it doesn't
// work when shebang is present at the top of the file.
ps.comments().get_vec().iter().find_map(|c| {
@@ -861,9 +861,8 @@ impl CodeActionCollection {
if let Some(ignore_comment) = maybe_ignore_comment {
new_text = format!(" {code}");
// Get the end position of the comment.
- let line = maybe_parsed_source
+ let line = maybe_text_info
.unwrap()
- .text_info()
.line_and_column_index(ignore_comment.end());
let position = lsp::Position {
line: line.line_index as u32,