Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Align `"..."` documentation for file pattern settings (#64452)

Dom Porada968be64a028e
diff --git a/crates/settings_content/src/project.rs b/crates/settings_content/src/project.rs
index acc89ccec82..0ad33c260b3 100644
--- a/crates/settings_content/src/project.rs
+++ b/crates/settings_content/src/project.rs
@@ -128,34 +128,67 @@ pub struct WorktreeSettingsContent {
#[serde(default)]
pub prevent_sharing_in_public_channels: bool,
- /// Completely ignore files matching globs from `file_scan_exclusions`. Overrides
- /// `file_scan_inclusions`.
- ///
- /// A `"..."` entry expands to the value being overridden, so
- /// `["**/node_modules", "..."]` adds to the inherited globs instead of
- /// replacing them. Leave `"..."` out to replace them.
- ///
- /// Default: [
- /// "**/.git",
- /// "**/.svn",
- /// "**/.hg",
- /// "**/.jj",
- /// "**/CVS",
- /// "**/.DS_Store",
- /// "**/Thumbs.db",
- /// "**/.classpath",
- /// "**/.settings"
- /// ]
+ /// Exclude files matching these glob patterns from file scans, file searches,
+ /// and the project file tree. Takes precedence over `file_scan_inclusions`.
+ ///
+ /// Default:
+ ///
+ /// ```json
+ /// {
+ /// "file_scan_exclusions": [
+ /// "**/.git",
+ /// "**/.svn",
+ /// "**/.hg",
+ /// "**/.jj",
+ /// "**/.sl",
+ /// "**/.repo",
+ /// "**/CVS",
+ /// "**/.DS_Store",
+ /// "**/Thumbs.db",
+ /// "**/.classpath",
+ /// "**/.settings"
+ /// ]
+ /// }
+ /// ```
+ ///
+ /// Use `"..."` to add patterns without repeating Zed’s defaults. In project
+ /// settings, it extends the user or parent configuration value. Omit
+ /// `"..."` to replace the inherited list.
+ ///
+ /// ```json
+ /// {
+ /// "file_scan_exclusions": ["**/node_modules", "..."]
+ /// }
+ /// ```
+ ///
+ /// Inherited patterns are inserted at `"..."`, and duplicates keep their first
+ /// occurrence.
pub file_scan_exclusions: Option<SplicingVec>,
- /// Always include files that match these globs when scanning for files, even
- /// if they’re ignored by Git. This setting is overridden by
- /// `file_scan_exclusions`.
+ /// Include files matching these glob patterns when scanning, even if ignored
+ /// by Git. Note that broad patterns can slow file scanning.
+ /// `file_scan_exclusions` takes precedence.
+ ///
+ /// Default:
///
- /// A "..." entry expands to the value being overridden. Leave "..." out to
- /// replace the inherited globs, or use an empty list to clear them.
+ /// ```json
+ /// {
+ /// "file_scan_inclusions": [".env*"]
+ /// }
+ /// ```
///
- /// Default: [".env*"]
+ /// Use `"..."` to add patterns without repeating Zed’s defaults. In project
+ /// settings, it extends the user or parent configuration value. Omit
+ /// `"..."` to replace the inherited list.
+ ///
+ /// ```json
+ /// {
+ /// "file_scan_inclusions": ["**/build/**", "..."]
+ /// }
+ /// ```
+ ///
+ /// Inherited patterns are inserted at `"..."`, and duplicates keep their first
+ /// occurrence.
pub file_scan_inclusions: Option<SplicingVec>,
/// When to scan content of linked directories.
@@ -182,14 +215,30 @@ pub struct WorktreeSettingsContent {
/// Default: ["**/.*"]
pub hidden_files: Option<Vec<String>>,
- /// Treat the files matching these globs as read-only. These files can be opened and viewed,
- /// but cannot be edited. This is useful for generated files, build outputs, or files from
- /// external dependencies that should not be modified directly.
+ /// Treat files matching these glob patterns as read-only when opened. You can
+ /// view but not edit them, which is useful for build outputs, external
+ /// dependencies, or generated files.
+ ///
+ /// Default:
+ ///
+ /// ```json
+ /// {
+ /// "read_only_files": []
+ /// }
+ /// ```
+ ///
+ /// Use `"..."` to add patterns without repeating Zed’s defaults. In project
+ /// settings, it extends the user or parent configuration value. Omit
+ /// `"..."` to replace the inherited list.
///
- /// A "..." entry expands to the value being overridden. Leave "..." out
- /// to replace the inherited globs, or use an empty list to clear them.
+ /// ```json
+ /// {
+ /// "read_only_files": ["**/build/**", "..."]
+ /// }
+ /// ```
///
- /// Default: []
+ /// Inherited patterns are inserted at `"..."`, and duplicates keep their first
+ /// occurrence.
pub read_only_files: Option<SplicingVec>,
}
diff --git a/docs/src/reference/all-settings.md b/docs/src/reference/all-settings.md
index 29f1162852d..acafc5bcb83 100644
--- a/docs/src/reference/all-settings.md
+++ b/docs/src/reference/all-settings.md
@@ -2332,7 +2332,7 @@ The result is still `)))` and not `))))))`, which is what it would be by default
## File Scan Exclusions
- Setting: `file_scan_exclusions`
-- Description: Files or globs of files that will be excluded by Zed entirely. They will be skipped during file scans, file searches, and not be displayed in the project file tree. Overrides `file_scan_inclusions`.
+- Description: Exclude files matching these glob patterns from file scans, file searches, and the project file tree. Takes precedence over `file_scan_inclusions`.
- Default:
```json [settings]
@@ -2353,7 +2353,7 @@ The result is still `)))` and not `))))))`, which is what it would be by default
}
```
-Note that specifying `file_scan_exclusions` in `settings.json` will override the defaults (listed above). Use `"..."` to keep them:
+Use `"..."` to add patterns without repeating Zed’s defaults. In project settings, it extends the user or parent configuration value. Omit `"..."` to replace the inherited list.
```json [settings]
{
@@ -2361,20 +2361,12 @@ Note that specifying `file_scan_exclusions` in `settings.json` will override the
}
```
-The `"..."` entry expands to the list you are overriding, so the example above excludes `node_modules` in addition to every default. Entries you list by name keep their position, and `"..."` fills in the inherited ones at that point in the list. If you want full control over what is excluded, omit `"..."` — only the entries you list by name will be used.
-
-| Configuration | Result |
-| ---------------------------- | ------------------------------------ |
-| `["..."]` | The defaults, unchanged |
-| `["**/node_modules", "..."]` | `**/node_modules`, then the defaults |
-| `["**/node_modules"]` | `**/node_modules` only |
-
-> Note: `"..."` resolves one settings layer at a time. In a project’s `.zed/settings.json` it expands to whatever your user settings resolved to, rather than to Zed’s defaults.
+Inherited patterns are inserted at `"..."`, and duplicates keep their first occurrence.
## File Scan Inclusions
- Setting: `file_scan_inclusions`
-- Description: Files or globs of files that will be included by Zed, even when ignored by git. This is useful for files that are not tracked by git, but are still important to your project. Note that globs that are overly broad can slow down Zed's file scanning. `file_scan_exclusions` takes precedence over these inclusions.
+- Description: Include files matching these glob patterns when scanning, even if ignored by Git. Note that broad patterns can slow file scanning. `file_scan_exclusions` takes precedence.
- Default:
```json [settings]
@@ -2383,17 +2375,15 @@ The `"..."` entry expands to the list you are overriding, so the example above e
}
```
-Use `"..."` to extend the inherited list instead of replacing it. In your user settings, it expands to Zed’s defaults. In a project’s `.zed/settings.json`, it expands to the resolved list from your user settings, including any defaults you kept.
-
-For example, add this to your settings.json to include generated files without repeating inherited patterns:
+Use `"..."` to add patterns without repeating Zed’s defaults. In project settings, it extends the user or parent configuration value. Omit `"..."` to replace the inherited list.
```json [settings]
{
- "file_scan_inclusions": ["...", "generated/**"]
+ "file_scan_inclusions": ["**/build/**", "..."]
}
```
-With the default user settings, this keeps `.env*` and adds `generated/**`. Omit `"..."` to replace the inherited list, or use `[]` to clear it. Duplicate patterns keep their first occurrence, even if `"..."` appears more than once. `file_scan_exclusions` still takes precedence.
+Inherited patterns are inserted at `"..."`, and duplicates keep their first occurrence.
## File Scan Depth
@@ -3908,21 +3898,25 @@ List of `string` glob patterns
## Read-Only Files {#read-only-files}
-- Default: `[]`
-- Description: Glob patterns for files you can open and view but cannot edit, such as generated files or external dependencies.
- Setting: `read_only_files`
-
-Add this to your project’s `.zed/settings.json`:
+- Description: Treat files matching these glob patterns as read-only when opened. You can view but not edit them, which is useful for build outputs, external dependencies, or generated files.
+- Default:
```json [settings]
{
- "read_only_files": ["**/generated/**", "..."]
+ "read_only_files": []
}
```
-Like [File Scan Exclusions](#file-scan-exclusions), `"..."` expands to the list inherited from the preceding settings layer. This example adds generated files to the read-only patterns from your user settings without repeating them. Duplicate entries collapse to their first occurrence.
+Use `"..."` to add patterns without repeating Zed’s defaults. In project settings, it extends the user or parent configuration value. Omit `"..."` to replace the inherited list.
+
+```json [settings]
+{
+ "read_only_files": ["**/build/**", "..."]
+}
+```
-Omit `"..."` to replace the inherited list, or use `[]` to clear it. These patterns apply when you open a file.
+Inherited patterns are inserted at `"..."`, and duplicates keep their first occurrence.
## Read SSH Config