Files
zed/crates/collab
HuaGu-DragonandKirill Bulatov 532532bb80 lsp: Filter out-of-bounds inlay hints (#64659)
# Objective

Fix the filtering of inlay hints around the buffer bounds.

The per-chunk range filter compared anchors, and anchor order includes
the bias.
A parameter hint (`anchor_before`) clamped to the end of the buffer
sorted before the chunk's end anchor and was kept, while a type/other
hint (`anchor_after`) exactly at the end of a file without a trailing
newline compared equal to it and was dropped.

Also remove the redundant `anyhow::Result` and `async` from the
LSP-to-project inlay hint conversion.

## Solution

- Drop LSP inlay hints whose line is past the last buffer row before
converting them.
Positions past a line's end are still clipped to the line end, as the
LSP spec prescribes for `Position.character`.
- Compare offsets instead of anchors in the per-chunk range filter, so
it does not depend on the hint's anchor bias, and treat the range end as
inclusive when it is the end of the buffer.
- Make `lsp_to_project_hint` a pure function over a `BufferSnapshot`.
The resolve path now converts the response against the same snapshot the
request position was produced from.

## Testing

- `test_inlay_hints_at_buffer_bounds`: row overflow for both hint kinds,
column overflow clipping on a non-last row, and a type hint exactly at
the buffer end.
  Fails on `main` on the row overflow and the buffer end cases.
- An out-of-bounds parameter hint added to the collab
`test_inlay_hint_refresh_is_forwarded`.
- Manually verified that rust-analyzer's closing brace hint appears
after the final `}` of a file without a trailing newline.

## 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:

- Fixed inlay hints positioned past the end of the buffer being shown on
its last line, and inlay hints exactly at the end of a file without a
trailing newline being hidden.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-23 19:04:52 +00:00
..
…
…
…

Zed Server

This crate is what we run at https://collab.zed.dev.

It contains our back-end logic for collaboration, to which we connect from the Zed client via a websocket after authenticating via https://zed.dev, which is a separate repo running on Vercel.

Local Development

Database setup

Before you can run the collab server locally, you'll need to set up a zed Postgres database. Follow the steps sequentially:

  1. Ensure you have postgres installed. If not, install with brew install postgresql@15.
  2. Follow the steps on Brew's formula and verify your $PATH contains /opt/homebrew/opt/postgresql@15/bin.
  3. If you hadn't done it before, create the postgres user with createuser -s postgres.
  4. You are now ready to run the bootstrap script:
script/bootstrap

This script will set up the zed Postgres database, and populate it with some users. It requires internet access, because it fetches some users from the GitHub API.

The script will create several admin users, who you'll sign in as by default when developing locally. The GitHub logins for the default users are specified in the seed.default.json file.

To use a different set of admin users, create crates/collab/seed.json.

{
  "admins": ["yourgithubhere"],
  "channels": ["zed"]
}

Testing collaborative features locally

In one terminal, run Zed's collaboration server and the livekit dev server:

foreman start

In a second terminal, run two or more instances of Zed.

script/zed-local -2

This script starts one to four instances of Zed, depending on the -2, -3 or -4 flags. Each instance will be connected to the local collab server, signed in as a different user from seed.json or seed.default.json.

Deployment

We run two instances of collab:

Both of these run on the Kubernetes cluster hosted in Digital Ocean.

Deployment is triggered by pushing to the collab-staging (or collab-production) tag in GitHub. The best way to do this is:

  • ./script/deploy-collab staging
  • ./script/deploy-collab production

You can tell what is currently deployed with ./script/what-is-deployed.