3d4f488d46d45ee7ec99f1038b804d476586a8e4
These changes refactor the whitespace handling logic for Vim's change surrounds command (`cs`), making its behavior closely match [tpope/vim-surround](https://github.com/tpope/vim-surround), following [this discussion](https://github.com/zed-industries/zed/issues/38169#issuecomment-3304129461). Zed's current implementation has two main differences when compared to [tpope/vim-surround](https://github.com/tpope/vim-surround): - It only considers whether a single space should be added or removed, instead of all the space that is between the surrounding character and the content - It only takes into consideration the new surrounding characters in order to determine whether to add or remove that space A review of [tpope/vim-surround](https://github.com/tpope/vim-surround)'s behavior reveals these rules for whitespace: * Quote to Quote * Whitespace is never changed * Quote to Bracket * If opening bracket, add one space * If closing bracket, do not add space * Bracket to Bracket * If opening to opening, keep only one space * If opening to closing, remove all space * If closing to opening, add one space * If closing to closing, do not change space * Bracket to Quote * If opening, remove all space * If closing, preserve all space Below is a table with examples for each scenario. A new test has also been added to specifically check the scenarios outlined above, `vim::surrounds::test::test_change_surrounds_vim`. | Type | Before | Command | After | |-------------------|-------------|---------|---------------| | Quote → Quote | `' a '` | `cs'"` | `" a "` | | Quote → Quote | `" a "` | `cs"'` | `' a '` | | Quote → Bracket | `' a '` | `cs'{` | `{ a }` | | Quote → Bracket | `' a '` | `cs'}` | `{ a }` | | Bracket → Bracket | `[ a ]` | `cs[{` | `{ a }` | | Bracket → Bracket | `[ a ]` | `cs[}` | `{a}` | | Bracket → Bracket | `[ a ]` | `cs]{` | `{ a }` | | Bracket → Bracket | `[ a ]` | `cs]}` | `{ a }` | | Bracket → Quote | `[ a ]` | `cs['` | `'a'` | | Bracket → Quote | `[ a ]` | `cs]'` | `' a '` | These changes diverge from [tpope/vim-surround](https://github.com/tpope/vim-surround) when handling newlines. For example, with the following snippet: ```rust fn test_surround() { if 2 > 1 { println!("place cursor here"); } }; ``` Placing the cursor inside the string and running any combination of `cs{[`, `cs{]`, `cs}[`, or `cs}]` would previously remove newline characters. With these changes, using commands like `cs}]` will now preserve newlines. Related to #38169 Closes #39334 Release Notes: - Improved Vim’s change surround command to closely match [tpope/vim-surround](https://github.com/tpope/vim-surround) behavior. --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Zed
Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Installation
On macOS and Linux you can download Zed directly or install Zed via your local package manager.
Other platforms are not yet available:
- Windows (tracking issue)
- Web (tracking issue)
Developing Zed
- Building Zed for macOS
- Building Zed for Linux
- Building Zed for Windows
- Running Collaboration Locally
Contributing
See CONTRIBUTING.md for ways you can contribute to Zed.
Also... we're hiring! Check out our jobs page for open roles.
Licensing
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.
Description
GPUI – Community Edition maintained by Oak Team
https://gpui-ce.github.io/
257 MiB
Languages
Rust
95.5%
WGSL
1.2%
Metal
1.1%
HLSL
1.1%
Python
0.7%
Other
0.3%