mirror of
https://github.com/zed-industries/zed.git
synced 2026-08-04 05:13:28 +00:00
10 commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
2268045a11
|
a11y: Landmarks and menu improvements (#60397)
Fixes menu a11y, and adds landmarks with `F6`-navigation. Also fixes a GPUI bug, and adds debug actions for dumping a11y tree info. Since `F6` was already in use by the pause debugger keybind, also tightens up the debugger keybind context so they require an active debugger session. When there is one active, `F6` stays as pause debugger. `ctrl-F6` always works to go to the next landmark. Also adds an "accessible mode" setting. Currently, this only controls whether we show all menus all the time, but I suspect it will expand significantly in the future. Also adds `.aria_keyshortcuts()` API, but it's not wired up within accesskit adapters, so is not yet reported to screen readers. --- Release Notes: - N/A or Added/Fixed/Improved ... |
||
|
|
f88bc7e18a
|
picker: Simplify presentation and sizing APIs, add preview-aware defaults (#59719)
Some checks are pending
Congratsbot / check-author (push) Waiting to run
Congratsbot / congrats (push) Blocked by required conditions
deploy_nightly_docs / deploy_docs (push) Waiting to run
run_tests / orchestrate (push) Waiting to run
run_tests / check_style (push) Waiting to run
run_tests / clippy_windows (push) Blocked by required conditions
run_tests / clippy_linux (push) Blocked by required conditions
run_tests / clippy_mac (push) Blocked by required conditions
run_tests / clippy_mac_x86_64 (push) Blocked by required conditions
run_tests / run_tests_windows (push) Blocked by required conditions
run_tests / run_tests_linux (push) Blocked by required conditions
run_tests / run_tests_mac (push) Blocked by required conditions
run_tests / miri_scheduler (push) Blocked by required conditions
run_tests / doctests (push) Blocked by required conditions
run_tests / check_workspace_binaries (push) Blocked by required conditions
run_tests / build_visual_tests_binary (push) Blocked by required conditions
run_tests / check_wasm (push) Blocked by required conditions
run_tests / check_dependencies (push) Blocked by required conditions
run_tests / check_docs (push) Blocked by required conditions
run_tests / check_licenses (push) Blocked by required conditions
run_tests / check_scripts (push) Blocked by required conditions
run_tests / check_postgres_and_protobuf_migrations (push) Blocked by required conditions
run_tests / extension_tests (push) Blocked by required conditions
run_tests / tests_pass (push) Blocked by required conditions
The recent "pickers with previews" overhaul left the picker
sizing/presentation API spread across several overlapping knobs that
every call site had to set correctly — and many didn't, causing pickers
across the app to render at the wrong width, lose their container, or
stop dismissing. This PR consolidates that surface into a small,
hard-to-misuse API and makes correct sizing the default.
Net effect: a plain `Picker::uniform_list(delegate, …)` now renders
correctly out of the box (standard width, standard max-height, shrinks
to fit, dismisses properly), and the ~35 call sites only specify what
genuinely differs.
## API changes
**Presentation** — three overlapping booleans (`is_modal`, `is_popover`,
`is_resizable`) collapsed into one enum, with resizability living inside
the only variant where it's meaningful:
```rust
enum Presentation {
Modal { resizable: bool }, // own chrome, dismisses on blur, optionally resizable
Popover, // own chrome, dismisses on blur, never resizable
Embedded, // host container owns chrome + dismissal
}
```
- `modal(bool)` is **removed** in favor of explicit, self-documenting
builders:
- *(default)* → `Modal` (resizable iff it has a preview)
- `.popover()` → `Popover` (menu-attached surfaces)
- `.embedded()` → `Embedded` (pickers nested in a larger modal/view)
- Dynamic callers use `.when(cond, Picker::embedded)` (added `impl
FluentBuilder for Picker`).
**Sizing** — preview-vs-not now drives everything; the manual padding
knob is gone:
| Before | After |
|---|---|
| `vertical_padding` field + `no_vertical_padding()` | removed — derived
from whether a preview is visible |
| `height(...)` (ambiguous: fixed vs max) | `max_height(...)` (plain
pickers shrink-to-fit, capped here) |
| `minimum_results_width(...)` | removed — a plain picker's min width
tracks its opening width; preview pickers use standard internal pane
mins |
| default size = 60% viewport | default = `DEFAULT_MODAL_WIDTH` (34rem)
× `DEFAULT_MODAL_MAX_HEIGHT` (24rem, max) |
| resize handles gated on `is_modal` | gated on `is_resizable` (new
`resizable(bool)` builder; auto-`true` for preview pickers) |
Call sites now only override the exceptions: narrow popover selectors
(`initial_width`), the taller outline view (`max_height`), and preview
pickers (constructed via `*_with_preview`).
## Behavior fixes
- **Wrong widths everywhere**: pickers were falling back to
60%-of-viewport because the original migration set
`minimum_results_width` but never `initial_width`. Fixed at the source
via the new defaults.
- **Popovers had no container and wouldn't dismiss**: `is_modal=false`
was suppressing both the elevated background *and* blur-dismiss. Split
out so popovers keep their chrome and dismiss on click-away/escape. This
fixed the agent-panel model/profile selectors, sidebar recent projects,
and the settings theme/font/icon/ollama pickers (which were incorrectly
using `modal(false)`).
- **Sidebar recent projects stretched to full height**: was missing the
shrink-to-fit behavior; now capped and content-sized like other
popovers.
- **Preview crash**: removed an over-strict `debug_assert!` that
panicked when previewing an empty file (`message == None && editor
empty` is valid).
- **Preview-aware default size**: pickers open at standard width with
the preview hidden, and expand to the larger "telescope" size when a
preview is shown. Fixes the text finder rendering super-wide by default,
and makes the file finder expand (rather than cram its results) when you
toggle the preview.
---
Release Notes:
- N/A
|
||
|
|
8c10715a4d
|
Migrate missed pickers to new width system (#59693)
# Objective - Fixes #59643. ## Problems - Initial and minimum width was not migrated for all pickers. - Some pickers had their width still determined by their wrapper. - Some pickers where not modals but did not have modal false set. ## Solution - Migrate the pickers we missed. - Remove the width being set on the div's wrapping the pickers. - Set modal false on the missed pickers. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - N/A |
||
|
|
ccf4058b7a
|
Add preview to pickers and make them resizable (#59604)
Overhauls Zed's pickers to make them resizable and give them a preview. Closes #8279 ### Background The most requested Zed feature has the last year has been a [Telescope like search box](https://github.com/zed-industries/zed/issues/8279) [discussion](https://github.com/zed-industries/zed/discussions/22581). To understand why this is so popular we need to understand search can serve thee goals: - Navigation: fuzzy search is faster & easier then clicking in a file tree - Exploration: example, find a function by a word in its doc comment - Collecting: example, getting a list of functions to change The project search which shows results in a multibuffer is the perfect way to operate on a list of items. Navigation and Exploration need a lot of context around each result and offer fast navigation between them. For both of these live searching is also critical. The `telescope UI` is a picker with a preview to the right or below. It's offered in various editors and IDE's most famously Neovim (through the Telescope plugin), IntelliJ (natively), Helix (natively) and of course VScode (plugins) and it's _many_ forks. While having a UI like that for text search (our project search) is most requested the UX pattern is applied widely, from `find_all_references` to `bookmarks`. It enhances most pickers. Note that we have over 50 different picker modals! The community has tried to build something like this for Zed: - https://github.com/zed-industries/zed/pull/44530 - https://github.com/zed-industries/zed/pull/45307 - https://github.com/zed-industries/zed/pull/46478 - https://github.com/zed-industries/zed/pull/43790 These all became huge PR's that we could not merge for various reasons. This is a really hard feature to integrate in Zed! This PR got started as https://github.com/zed-industries/zed/pull/46478 and supercedes that. ### Design - Extend pickers to support an optional preview with minimal changes to the pickers themselves. - Make pickers resizable. - Complement the existing search do not replace it by having both UI's share the underlying search and allow freely switching between them. - Allow extending the preview to things other then files. - Maintain a clean design on all the pickers. ### Heigh level Implementation overview - Adds an `Option<Preview>` to `Picker` - Gives `PickerDelegate` a method to communicate a preview to the Picker - Overhaul the way pickers are drawn to allow for resizing them. Implemented on the `Shape` and `SizeBouds` structs. - Adds a high level way to draw the `footer` and `editor` so we do not need to change much to the pickers. - Adds a new text finder Picker - Adds a way to take a running search from project search and hand it to the text finder Picker and the other way round - Give the file finder a preview ### Next steps A more detailed list and how to help out will be added to the tracking issue for [Pickes with previews](https://github.com/zed-industries/zed/issues/56037) - Add more previews to more pickers! - Enable selectioning multiple items in pickers and performing actions on those - Open selected items in a multibuffer - Add a way to restore the last picker - Make popovers (picker attached to some menu) resizable as well ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Showcase TODO (will be done post merge) --- Release Notes: - Added resizing via dragging to all picker modals. - Added a preview to the File finder, the preview can be to the right or below. - Added a Text finder picker with a preview as alternative project search UI. The search is shared and allowes switch between UIs while running. --------- Co-authored-by: ozacod <47009516+ozacod@users.noreply.github.com> Co-authored-by: ozacod <ozacod@users.noreply.github.com> Co-authored-by: Danilo Leal <daniloleal09@gmail.com> |
||
|
|
c049193fd9
|
Make all status bar tools able to hide its button via UI (#54971)
Closes https://github.com/zed-industries/zed/discussions/53471 Adds a requirement on status bar items to provide a way to hide themselves. <img width="329" height="153" alt="image" src="https://github.com/user-attachments/assets/b98ee5ba-a439-44d7-9ab5-f4511b66a574" /> <img width="464" height="40" alt="image" src="https://github.com/user-attachments/assets/b41d9189-3475-4e61-b3a4-bc731dd52c53" /> Release Notes: - Added a way to hide sidebar buttons |
||
|
|
2a15bf630d
|
Require multibuffer excerpts to be ordered and nonoverlapping (#52364)
TODO:
- [x] merge main
- [x] nonshrinking `set_excerpts_for_path`
- [x] Test-drive potential problem areas in the app
- [x] prepare cloud side
- [x] test collaboration
- [ ] docstrings
- [ ] ???
## Context
### Background
Currently, a multibuffer consists of an arbitrary list of
anchor-delimited excerpts from individual buffers. Excerpt ranges for a
fixed buffer are permitted to overlap, and can appear in any order in
the multibuffer, possibly separated by excerpts from other buffers.
However, in practice all code that constructs multibuffers does so using
the APIs defined in the `path_key` submodule of the `multi_buffer` crate
(`set_excerpts_for_path` etc.) If you only use these APIs, the resulting
multibuffer will maintain the following invariants:
- All excerpts for the same buffer appear contiguously in the
multibuffer
- Excerpts for the same buffer cannot overlap
- Excerpts for the same buffer appear in order
- The placement of the excerpts for a specific buffer in the multibuffer
are determined by the `PathKey` passed to `set_excerpts_for_path`. There
is exactly one `PathKey` per buffer in the multibuffer
### Purpose of this PR
This PR changes the multibuffer so that the invariants maintained by the
`path_key` APIs *always* hold. It's no longer possible to construct a
multibuffer with overlapping excerpts, etc. The APIs that permitted
this, like `insert_excerpts_with_ids_after`, have been removed in favor
of the `path_key` suite.
The main upshot of this is that given a `text::Anchor` and a
multibuffer, it's possible to efficiently figure out the unique excerpt
that includes that anchor, if any:
```
impl MultiBufferSnapshot {
fn buffer_anchor_to_anchor(&self, anchor: text::Anchor) -> Option<multi_buffer::Anchor>;
}
```
And in the other direction, given a `multi_buffer::Anchor`, we can look
at its `text::Anchor` to locate the excerpt that contains it. That means
we don't need an `ExcerptId` to create or resolve
`multi_buffer::Anchor`, and in fact we can delete `ExcerptId` entirely,
so that excerpts no longer have any identity outside their
`Range<text::Anchor>`.
There are a large number of changes to `editor` and other downstream
crates as a result of removing `ExcerptId` and multibuffer APIs that
assumed it.
### Other changes
There are some other improvements that are not immediate consequences of
that big change, but helped make it smoother. Notably:
- The `buffer_id` field of `text::Anchor` is no longer optional.
`text::Anchor::{MIN, MAX}` have been removed in favor of
`min_for_buffer`, etc.
- `multi_buffer::Anchor` is now a three-variant enum (inlined slightly):
```
enum Anchor {
Min,
Excerpt {
text_anchor: text::Anchor,
path_key_index: PathKeyIndex,
diff_base_anchor: Option<text::Anchor>,
},
Max,
}
```
That means it's no longer possible to unconditionally access the
`text_anchor` field, which is good because most of the places that were
doing that were buggy for min/max! Instead, we have a new API that
correctly resolves min/max to the start of the first excerpt or the end
of the last excerpt:
```
impl MultiBufferSnapshot {
fn anchor_to_buffer_anchor(&self, anchor: multi_buffer::Anchor) -> Option<text::Anchor>;
}
```
- `MultiBufferExcerpt` has been removed in favor of a new
`map_excerpt_ranges` API directly on `MultiBufferSnapshot`.
## Self-Review Checklist
<!-- Check before requesting review: -->
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable
Release Notes:
- N/A
---------
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
Co-authored-by: Conrad <conrad@zed.dev>
|
||
|
|
83de8a25e0
|
Revert PRs for landing in main (#48969)
We're going to re-apply these after landing the multiworkspace branch. Release Notes: - N/A |
||
|
|
f233ae4c29
|
Add telemetry for user-facing notifications (#48558)
## Summary Adds a "Notification Shown" telemetry event that fires whenever a user-facing notification is displayed in Zed. This helps the team understand error patterns, notification frequency, and which parts of the application generate the most notifications. ## Event Schema | Property | Type | Description | |----------|------|-------------| | `notification_type` | `string` | `"error"` or `"notification"` | | `source` | `string` | Origin category (e.g., `lsp`, `git`, `settings`, `editor`) | | `lsp_name` | `string?` | Language server name (only for LSP notifications) | | `level` | `string?` | Severity: `"critical"`, `"warning"`, or `"info"` | | `has_actions` | `bool` | Whether the notification has action buttons | | `notification_id` | `string` | Debug string of the NotificationId | | `is_auto_dismissing` | `bool` | Whether the notification auto-dismisses | ## NotificationSource Categories A new `NotificationSource` enum categorizes notifications by origin: - `lsp` - Language server notifications - `settings` - Settings/keymap parse errors - `update` - App updates, release notes - `extension` - Extension suggestions/errors - `git` - Git operations, commit errors - `project` - Project-level issues - `collab` - Collaboration notifications - `remote` - SSH/remote project errors - `file` - File access errors - `editor` - Editor operations (search, encoding) - `agent` - AI assistant notifications - `cli` - CLI installation - `system` - Generic fallback ## Privacy **Message content is intentionally not included** in telemetry because: - LSP messages come from external servers and may contain file paths or error chains - Error messages may contain sensitive paths or API-related information - The metadata alone provides sufficient insight for error tracking ## Implementation Updated function signatures to include `NotificationSource`: - `show_notification(id, source, cx, build_fn)` - `show_toast(toast, source, cx)` - `show_error(err, source, cx)` - `show_app_notification(id, source, cx, build_fn)` - `notify_err(workspace, source, cx)` - `notify_async_err(source, cx)` - `notify_app_err(source, cx)` - `detach_and_notify_err(source, window, cx)` Release Notes - N/A (internal telemetry change) --------- Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com> |
||
|
|
8e291ec404
|
encoding: Add "reopen with encoding" (#46553)
# Add "Reopen with Encoding" feature (Local/Single user) ## Summary This PR adds a "Reopen with Encoding" feature to allow users to manually specify an encoding and reload the active buffer. This feature allows users to explicitly specify the encoding and reload the file to resolve garbled text caused by incorrect detection. ## Changes 1. Added encoding picker logic to `encoding_selector` - Implemented a modal UI accessible via the command palette, shortcuts, or by clicking the encoding status in the status bar. - Allows users to select from a list of supported encodings (Shift JIS, EUC-JP, UTF-16LE, etc.). 2. Updated Buffer logic (crates/language) - Added a `force_encoding_on_next_reload` flag to the Buffer struct. - Updated the `reload` method to check this flag and apply the following logic: - **Non-Unicode (e.g., Shift JIS):** Bypasses heuristics (like BOM checks) to force the specified encoding. - **Unicode (e.g., UTF-8):** Performs standard BOM detection. This ensures that the BOM is correctly handled/consumed when switching back to UTF-8. 3. UI / Keymap - Made the encoding status in the status bar (ActiveBufferEncoding) clickable. - Added default keybindings: - macOS: cmd-k n - Linux/Windows: ctrl-k n - Windows: ctrl-k n ## Limitations & Scope To ensure stability and keep the PR focused, the following scenarios are intentionally out of scope: 1. **Collaboration and Remote Connections** - Encoding changes are disabled when collaboration (is_shared) or SSH remote connections (is_via_remote_server) are active. - **Reason:** Synchronizing encoding state changes between host/guest or handling remote reloads involves complex synchronization logic. This PR focuses on local files only. `Remote Connection (SSH/WSL)` |Via status bar|Via shortcut/command| |:---:|:---:| |<img width="767" height="136" alt="remote_tooltip" src="https://github.com/user-attachments/assets/6c7cb293-2486-4f6d-a3ff-2086d939398e" width="400" />|<img width="742" height="219" alt="remote_shortcut" src="https://github.com/user-attachments/assets/5448f199-2066-4baf-b349-a983ab2fa77a" width="400" />| `Collaboration Session ` |Via status bar|Via shortcut/command| |:---:|:---:| |<img width="734" height="86" alt="collab_tooltip" src="https://github.com/user-attachments/assets/37de99a9-dd33-4c78-98bf-20654d41fdd0" />|<img width="720" height="182" alt="collab_pop" src="https://github.com/user-attachments/assets/91d03ea7-f029-442a-8236-55234576f7ed" />| 2. Dirty State - The feature is disabled if the buffer has unsaved changes to prevent data loss during reload. |Via status bar|Via shortcut/command| |:---:|:---:| |<img width="545" height="103" alt="local_dirty_tooltip" src="https://github.com/user-attachments/assets/d9ae658e-52b3-4ecd-9873-d0ec8bd51b5d" />|<img width="707" height="178" alt="local_dirty_pop" src="https://github.com/user-attachments/assets/d170ea1e-9fcb-42e7-aa3e-0555b4a19d86" />| 3. Files detected as Binary Files that worktree detects as "binary" (e.g., UTF-16 files without BOM containing non-ASCII characters) are not opened in the editor, so this feature cannot be triggered. **Future Work**: Fixing this would require modifying crates/worktree heuristics or exposing a "Force Open as Text" action for InvalidItemView to trigger. Given the scope and impact, this is deferred to a future PR. ## Test Plan I verified the feature and BOM handling using the following scenarios: ### Preparation Used the following test files: - [**test_utf8.txt**](https://github.com/user-attachments/files/24548803/test_utf8.txt): English-only text file. No BOM. - [**test_utf8_bom.txt**](https://github.com/user-attachments/files/24548822/test_utf8_bom.txt): English-only text file. With BOM. - [**test_utf8_jp_bom.txt**](https://github.com/user-attachments/files/24548825/test_utf8_jp_bom.txt): UTF-8 with BOM file containing Japanese characters. - [**test_shiftjis_jp.txt**](https://github.com/user-attachments/files/24548827/test_shiftjis_jp.txt): Shift-JIS file containing Japanese characters (content designed to trigger misdetection, e.g., using only half-width katakana). Used an external editor (VS Code or Notepad) for verification. ### Case 1: English-only file behavior 1. Open an English-only UTF-8 file (test_utf8.txt). 2. Reopen as Shift JIS. 3. **Result:** - Text appearance remains unchanged (since ASCII is compatible). - Status bar updates to "Shift JIS". ### Case 2: Fixing Mojibake 1. Open a Shift-JIS file (test_shiftjis_jp.txt) that causes detection failure. ※Confirm it opens with mojibake 2. Select Shift JIS from the status bar selector. 3. **Result:** - Mojibake is resolved, and Japanese text is displayed correctly. - Status bar updates to "Shift JIS". ### Case 3: Unicode file with BOM behavior 1. Open an English-only UTF-8 with BOM file (test_utf8_bom.txt). 2. Reopen as `Shift JIS`. 3. **Result:** - The BOM bytes are displayed as mojibake at the beginning of the file. - The rest of the English text is displayed normally (ASCII compatibility). - Status bar updates to "Shift JIS". ### Case 4: Non-Unicode file with BOM behavior 1. Open a UTF-8 with BOM file containing Japanese (test_utf8_jp_bom.txt). 2. Reopen as Shift JIS. 3. **Result:** - The BOM bytes at the start are displayed as mojibake. - The Japanese text body is displayed as mojibake (UTF-8 bytes interpreted as Shift JIS). - Status bar updates to "Shift JIS" (no BOM indicator). ### Case 5: Revert to Unicode 1. From the state in Case 4 (Shift JIS with mojibake), reopen as UTF-8. 2. **Result:** - The BOM mojibake at the start disappears (consumed). - The text returns to normal. - Status bar updates to "UTF-8 (BOM)". ### Case 6: External BOM removal (State sync) 1. Open a UTF-8 with BOM file in Zed (test_utf8_bom.txt). 2. Open the same file in an external editor and save it as UTF-8 (No BOM). 3. Refocus Zed. 4. **Result:** - Text appearance remains unchanged. - The (BOM) indicator disappears from the status bar. - Saving in Zed and checking externally confirms the BOM is gone. ### Case 7: External BOM addition 1. From the state in Case 6 (UTF-8 No BOM), save as UTF-8 with BOM in the external editor. 2. Refocus Zed. 3. **Result:** - The (BOM) indicator appears in the status bar. - Saving in Zed and checking externally confirms the BOM is present. ### Case 8: External Encoding Change (Auto-detect sync) 1. Open an English-only UTF-8 file in Zed (`test_utf8.txt`). * *Status bar shows: "UTF-8".* 2. Open the same file in an external editor and save it as **UTF-16LE with BOM**. 3. Refocus Zed. 4. **Result:** * The text remains readable (no mojibake). * **Status bar automatically updates to "UTF-16LE (BOM)".** (Verifies that `buffer.encoding` is correctly updated during reload). Release Notes: - Added "Reopen with Encoding" feature (currently supported for local files). --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com> |
||
|
|
6b90aaa1bd
|
status_bar: Add encoding indicator (#45476)
## Context / Related PRs This PR is the third part of the encoding support improvements, following: - #44819: Introduced initial legacy encoding support (Shift-JIS, etc.). - #45243: Fixed UTF-16 saving behavior and improved binary detection. ## Summary This PR implements a status bar item that displays the character encoding of the active buffer (e.g., `UTF-8`, `Shift_JIS`). It provides visibility into the file's encoding and indicates the presence of a Byte Order Mark (BOM). ## Features - **Encoding Indicator**: Displays the encoding name in the status bar. - **BOM Support**: Appends `(BOM)` to the encoding name if a BOM is detected (e.g., `UTF-8 (BOM)`). - **Configuration**: The active_encoding_button setting in status_bar accepts "enabled", "disabled", or "non_utf8". The default is "non_utf8", which displays the indicator for all encodings except standard UTF-8 (without BOM). - **Settings UI**: Provides a dropdown menu in the Settings UI to control this behavior. - **Documentation**: Updated `configuring-zed.md` and `visual-customization.md`. ## Implementation Details - Created `ActiveBufferEncoding` component in `crates/encoding_selector`. - The click handler for the button is currently a **no-op**. Implementing the functionality to reopen files with a specific encoding has potential implications for real-time collaboration (e.g., syncing buffer interpretation across peers). Therefore, this PR focuses strictly on the visualization and configuration aspects to keep the scope simple and focused. - Updated schema and default settings to include `active_encoding_button`. ## Screenshots <img width="487" height="104" alt="image" src="https://github.com/user-attachments/assets/041f096d-ac69-4bad-ac53-20cdcb41f733" /> <img width="454" height="99" alt="image" src="https://github.com/user-attachments/assets/ed76daa2-2733-484f-bb1f-4688357c035a" /> ## Configuration To hide the button, add the following to `settings.json`: ```json "status_bar": { "active_encoding_button": "disabled" } ``` - **enabled**: Always show the encoding. - **disabled**: Never show the encoding. - **non_utf8**: Shows for non-UTF-8 encodings and UTF-8 with BOM. Only hides for standard UTF-8 (Default). <img width="1347" height="415" alt="image" src="https://github.com/user-attachments/assets/7f4f4938-3320-4d21-852c-53ee886d9a44" /> ## Heuristic Limitations: The underlying detection logic (implemented in #44819 and #45243) prioritizes UTF-8 opening performance and does not guarantee perfect detection for all encodings. We consider this margin of error acceptable, similar to the behavior seen in VS Code. A future "Reopen with Encoding" feature would serve as the primary fallback for any misdetections. Release Notes: - Added a status bar item to display the active file's character encoding (e.g. `UTF-16`). This shows for non-utf8 files by default and can be configured with `{"status_bar":{"active_encoding_button":"disabled|enabled|non_utf8"}}` |