summaryrefslogtreecommitdiff
path: root/cli/args/mod.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-06-13 15:48:53 -0400
committerGitHub <noreply@github.com>2023-06-13 15:48:53 -0400
commit015ea60d25a3c773fc9d9bf17fc904de236814f9 (patch)
tree7ad367b85a48fc5c0980bbfd91e98139d9f9da19 /cli/args/mod.rs
parent92e7287f4a744cad1fbe46ba1ce84c2b479ce6ac (diff)
fix(lsp): don't pre-load documents matched in the config file's "exclude" (#19431)
This prevents documents specified in a deno.json's "exclude" from being pre-loaded by the lsp. For example, someone may have something like: ```jsonc // deno.json { "exclude": [ "dist" // build directory ] } ```
Diffstat (limited to 'cli/args/mod.rs')
-rw-r--r--cli/args/mod.rs39
1 files changed, 3 insertions, 36 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs
index 98e8f3564..ef5d3119e 100644
--- a/cli/args/mod.rs
+++ b/cli/args/mod.rs
@@ -71,6 +71,7 @@ use crate::file_fetcher::FileFetcher;
use crate::npm::CliNpmRegistryApi;
use crate::npm::NpmProcessState;
use crate::util::fs::canonicalize_path_maybe_not_exists;
+use crate::util::glob::expand_globs;
use crate::version;
use self::config_file::FmtConfig;
@@ -1312,40 +1313,6 @@ impl StorageKeyResolver {
}
}
-fn expand_globs(paths: &[PathBuf]) -> Result<Vec<PathBuf>, AnyError> {
- let mut new_paths = vec![];
- for path in paths {
- let path_str = path.to_string_lossy();
- if path_str.chars().any(|c| matches!(c, '*' | '?')) {
- // Escape brackets - we currently don't support them, because with introduction
- // of glob expansion paths like "pages/[id].ts" would suddenly start giving
- // wrong results. We might want to revisit that in the future.
- let escaped_path_str = path_str.replace('[', "[[]").replace(']', "[]]");
- let globbed_paths = glob::glob_with(
- &escaped_path_str,
- // Matches what `deno_task_shell` does
- glob::MatchOptions {
- // false because it should work the same way on case insensitive file systems
- case_sensitive: false,
- // true because it copies what sh does
- require_literal_separator: true,
- // true because it copies with sh does—these files are considered "hidden"
- require_literal_leading_dot: true,
- },
- )
- .with_context(|| format!("Failed to expand glob: \"{}\"", path_str))?;
-
- for globbed_path_result in globbed_paths {
- new_paths.push(globbed_path_result?);
- }
- } else {
- new_paths.push(path.clone());
- }
- }
-
- Ok(new_paths)
-}
-
/// Collect included and ignored files. CLI flags take precedence
/// over config file, i.e. if there's `files.ignore` in config file
/// and `--ignore` CLI flag, only the flag value is taken into account.
@@ -1364,11 +1331,11 @@ fn resolve_files(
}
// Now expand globs if there are any
if !result.include.is_empty() {
- result.include = expand_globs(&result.include)?;
+ result.include = expand_globs(result.include)?;
}
if !result.exclude.is_empty() {
- result.exclude = expand_globs(&result.exclude)?;
+ result.exclude = expand_globs(result.exclude)?;
}
Ok(result)