diff options
Diffstat (limited to 'cli/lsp')
-rw-r--r-- | cli/lsp/config.rs | 13 | ||||
-rw-r--r-- | cli/lsp/documents.rs | 20 |
2 files changed, 23 insertions, 10 deletions
diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index 3d24c8c20..120828a79 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -1083,7 +1083,7 @@ impl Config { pub fn get_disabled_paths(&self) -> PathOrPatternSet { let mut path_or_patterns = vec![]; if let Some(cf) = self.maybe_config_file() { - if let Some(files) = cf.to_files_config().ok().flatten() { + if let Ok(files) = cf.to_files_config() { for path in files.exclude.into_path_or_patterns() { path_or_patterns.push(path); } @@ -1095,7 +1095,14 @@ impl Config { continue; }; let settings = self.workspace_settings_for_specifier(workspace_uri); - if settings.enable.unwrap_or_else(|| self.has_config_file()) { + let is_enabled = settings + .enable_paths + .as_ref() + .map(|p| !p.is_empty()) + .unwrap_or_else(|| { + settings.enable.unwrap_or_else(|| self.has_config_file()) + }); + if is_enabled { for path in &settings.disable_paths { path_or_patterns.push(PathOrPattern::Path(workspace_path.join(path))); } @@ -1177,7 +1184,7 @@ fn specifier_enabled( workspace_folders: &[(Url, lsp::WorkspaceFolder)], ) -> bool { if let Some(cf) = config_file { - if let Some(files) = cf.to_files_config().ok().flatten() { + if let Ok(files) = cf.to_files_config() { if !files.matches_specifier(specifier) { return false; } diff --git a/cli/lsp/documents.rs b/cli/lsp/documents.rs index b825bc020..7912dad78 100644 --- a/cli/lsp/documents.rs +++ b/cli/lsp/documents.rs @@ -1341,11 +1341,12 @@ impl Documents { .inner() .iter() .map(|p| match p { - PathOrPattern::Path(p) => { - Cow::Owned(p.to_string_lossy().to_string()) + PathOrPattern::Path(p) => p.to_string_lossy(), + PathOrPattern::NegatedPath(p) => { + Cow::Owned(format!("!{}", p.to_string_lossy())) } PathOrPattern::RemoteUrl(p) => Cow::Borrowed(p.as_str()), - PathOrPattern::Pattern(p) => Cow::Borrowed(p.as_str()), + PathOrPattern::Pattern(p) => p.as_str(), }) .collect::<Vec<_>>(); // ensure these are sorted so the hashing is deterministic @@ -2061,8 +2062,13 @@ impl Iterator for PreloadDocumentFinder { if let Ok(entry) = entry { let path = entry.path(); if let Ok(file_type) = entry.file_type() { - if file_patterns.matches_path(&path) { - if file_type.is_dir() && is_discoverable_dir(&path) { + let is_dir = file_type.is_dir(); + let path_kind = match is_dir { + true => deno_config::glob::PathKind::Directory, + false => deno_config::glob::PathKind::File, + }; + if file_patterns.matches_path(&path, path_kind) { + if is_dir && is_discoverable_dir(&path) { self.pending_entries.push_back(PendingEntry::Dir( path.to_path_buf(), file_patterns.clone(), @@ -2354,7 +2360,7 @@ console.log(b, "hello deno"); file_patterns: FilePatterns { base: temp_dir.path().to_path_buf(), include: Some( - PathOrPatternSet::from_relative_path_or_patterns( + PathOrPatternSet::from_include_relative_path_or_patterns( temp_dir.path().as_path(), &[ "root1".to_string(), @@ -2415,7 +2421,7 @@ console.log(b, "hello deno"); file_patterns: FilePatterns { base: temp_dir.path().to_path_buf(), include: Default::default(), - exclude: PathOrPatternSet::from_relative_path_or_patterns( + exclude: PathOrPatternSet::from_exclude_relative_path_or_patterns( temp_dir.path().as_path(), &[ "root1".to_string(), |