## Summary Sister to Shopify/ruby-lsp#4242. Pressing Enter triggers `textDocument/onTypeFormatting` from inside the newline transaction, before autoindent has been applied. The request position was converted to a point at that moment, so language servers received column 0 of the new line even though the cursor ends up at the indented column. The left-biased cursor pins from #61823 were captured at the same moment, so the autoindent whitespace prevented them from being restored. With Ruby LSP this inserted `end` in front of the body's indentation and left the cursor after `end`. That is why the Ruby extension disables on-type formatting (zed-extensions/ruby#38). This PR: - Resolves the on-type formatting position after pending autoindent is applied. - Capture the cursor pins after pending autoindent is applied. ## Testing - `cargo test -p editor --lib on_type_format` (7 passed; the 2 new tests fail on `main`) - `cargo test -p collab --features test-support --test collab_tests on_input_format` (2 passed) - `./script/clippy -p editor -p project` - Manually with Ruby LSP: `def foo⏎`, `do |x|⏎`, heredocs, `do |` and `"#{` ### Proof https://github.com/user-attachments/assets/43ff3307-4bd7-43f5-a65d-d18eca0b5d2a ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. ## References - zed-extensions/ruby#38 - Follow-up to #61823 ## Suggested .rules additions For `crates/editor/.rules`: code that runs inside `Editor::transact` (for example from `newline`) sees the buffer before autoindent is applied. Wait for `Buffer::wait_for_autoindent_applied()` before reading cursor positions or anchoring to them. Release Notes: - Fixed on-type formatting after pressing Enter being applied before the new line's indentation, which left the cursor after text inserted by language servers such as Ruby LSP. |
||
|---|---|---|
| .agents/skills | ||
| .cargo | ||
| .cloudflare | ||
| .config | ||
| .factory | ||
| .github | ||
| .wezel | ||
| .zed | ||
| assets | ||
| ci | ||
| crates | ||
| docs | ||
| extensions | ||
| legal | ||
| nix | ||
| script | ||
| tooling | ||
| .git-blame-ignore-revs | ||
| .gitattributes | ||
| .gitignore | ||
| .mailmap | ||
| .prettierrc | ||
| .rules | ||
| AGENTS.md | ||
| Cargo.lock | ||
| Cargo.toml | ||
| CLAUDE.md | ||
| clippy.toml | ||
| CODE_OF_CONDUCT.md | ||
| compose.yml | ||
| CONTRIBUTING.md | ||
| corgi.toml | ||
| default.nix | ||
| Dockerfile-collab | ||
| Dockerfile-collab.dockerignore | ||
| Dockerfile-cross.dockerignore | ||
| Dockerfile-distros | ||
| Dockerfile-distros.dockerignore | ||
| flake.lock | ||
| flake.nix | ||
| GEMINI.md | ||
| LICENSE-APACHE | ||
| LICENSE-GPL | ||
| Procfile | ||
| Procfile.web | ||
| README.md | ||
| rust-toolchain.toml | ||
| rustfmt.toml | ||
| shell.nix | ||
Zed
Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Installation
On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).
Other platforms are not yet available:
- Web (tracking discussion)
Developing Zed
Contributing
See CONTRIBUTING.md for ways you can contribute to Zed.
Also... we're hiring! Check out our jobs page for open roles.
Licensing
Zed source code is licensed primarily under GPL-3.0-or-later, with Apache-2.0 components where marked.
License information for third party dependencies must be correctly provided for CI to pass.
We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:
- Is it showing a
no license specifiederror for a crate you've created? If so, addpublish = falseunder[package]in your crate's Cargo.toml. - Is the error
failed to satisfy license requirementsfor a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to theacceptedarray inscript/licenses/zed-licenses.toml. - Is
cargo-aboutunable to find the license for a dependency? If so, add a clarification field at the end ofscript/licenses/zed-licenses.toml, as specified in the cargo-about book.
Sponsorship
Zed is developed by Zed Industries, Inc., a for-profit company.
If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.