mirror of
https://github.com/zed-industries/zed.git
synced 2026-08-16 04:24:31 +00:00
## Context
JSON rainbow bracket colors could shift across row chunk boundaries when
large ancestor objects were omitted by the bounded tree-sitter bracket
query window. This fixes the chunk-local depth reset by caching bracket
chunk data together with the active bracket stack after each chunk, then
using that inherited stack when later chunks are computed. For JSON
object braces that are too large for the bounded query, the
implementation recovers active ancestor `{...}` pairs from the syntax
tree so sibling object braces keep the same color even when jumping
directly to a later chunk.
Closes #50185
## How to Review
`crates/language/src/buffer/row_chunk.rs` adds indexed access to row
chunks so bracket cache computation can walk from the nearest cached
chunk up to the requested chunk.
`crates/language/src/buffer.rs` changes bracket range caching from
storing only per-chunk matches to storing per-chunk matches plus the
active bracket stack after that chunk. It preserves the existing bounded
query and greedy-match repair behavior, while adding JSON-specific
ancestor recovery for large object braces omitted by
`MAX_BYTES_TO_QUERY`.
`crates/language/src/buffer_tests.rs` adds a JSON regression fixture
that exceeds `MAX_BYTES_TO_QUERY`, fetches a later chunk before earlier
chunks, and verifies all same-depth sibling object braces keep the same
`color_index` across row chunks.
Video of manual test below :
[Screencast from 2026-07-10
08-09-30.webm](https://github.com/user-attachments/assets/fca6425b-b79c-4097-b4af-148db6aa23d9)
## Self-Review Checklist
- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the UI/UX checklist
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable
Release Notes:
- Fixed JSON rainbow bracket colors changing across row chunk
boundaries.
---------
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
118 lines
3.1 KiB
TOML
118 lines
3.1 KiB
TOML
[package]
|
|
name = "language"
|
|
version = "0.1.0"
|
|
edition.workspace = true
|
|
publish.workspace = true
|
|
license = "GPL-3.0-or-later"
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[lib]
|
|
path = "src/language.rs"
|
|
doctest = false
|
|
|
|
[features]
|
|
test-support = [
|
|
"rand",
|
|
"collections/test-support",
|
|
"grammars",
|
|
"lsp/test-support",
|
|
"text/test-support",
|
|
"tree-sitter-rust",
|
|
"tree-sitter-python",
|
|
"tree-sitter-typescript",
|
|
"tree-sitter-json",
|
|
"tree-sitter-md",
|
|
"settings/test-support",
|
|
"util/test-support",
|
|
]
|
|
|
|
[dependencies]
|
|
anyhow.workspace = true
|
|
async-trait.workspace = true
|
|
clock.workspace = true
|
|
collections.workspace = true
|
|
ec4rs.workspace = true
|
|
encoding_rs.workspace = true
|
|
fs.workspace = true
|
|
futures.workspace = true
|
|
futures-lite.workspace = true
|
|
fuzzy_nucleo.workspace = true
|
|
globset.workspace = true
|
|
gpui.workspace = true
|
|
http_client.workspace = true
|
|
imara-diff.workspace = true
|
|
language_core.workspace = true
|
|
itertools.workspace = true
|
|
log.workspace = true
|
|
lsp.workspace = true
|
|
parking_lot.workspace = true
|
|
postage.workspace = true
|
|
rand = { workspace = true, optional = true }
|
|
regex.workspace = true
|
|
rpc.workspace = true
|
|
semver.workspace = true
|
|
serde.workspace = true
|
|
serde_json.workspace = true
|
|
settings.workspace = true
|
|
shellexpand.workspace = true
|
|
smallvec.workspace = true
|
|
streaming-iterator.workspace = true
|
|
strsim.workspace = true
|
|
sum_tree.workspace = true
|
|
task.workspace = true
|
|
text.workspace = true
|
|
theme.workspace = true
|
|
toml.workspace = true
|
|
tracing.workspace = true
|
|
grammars = { workspace = true, optional = true }
|
|
tree-sitter-json = { workspace = true, optional = true }
|
|
tree-sitter-md = { workspace = true, optional = true }
|
|
tree-sitter-python = { workspace = true, optional = true }
|
|
tree-sitter-rust = { workspace = true, optional = true }
|
|
tree-sitter-typescript = { workspace = true, optional = true }
|
|
tree-sitter = { workspace = true, features = ["wasm"] }
|
|
unicase = "2.6"
|
|
util.workspace = true
|
|
watch.workspace = true
|
|
zlog.workspace = true
|
|
ztracing.workspace = true
|
|
diffy = "0.4.2"
|
|
|
|
[dev-dependencies]
|
|
collections = { workspace = true, features = ["test-support"] }
|
|
ctor.workspace = true
|
|
grammars.workspace = true
|
|
gpui = { workspace = true, features = ["test-support"] }
|
|
indoc.workspace = true
|
|
lsp = { workspace = true, features = ["test-support"] }
|
|
pretty_assertions.workspace = true
|
|
rand.workspace = true
|
|
settings = { workspace = true, features = ["test-support"] }
|
|
text = { workspace = true, features = ["test-support"] }
|
|
http_client = { workspace = true, features = ["test-support"] }
|
|
tree-sitter-elixir.workspace = true
|
|
tree-sitter-embedded-template.workspace = true
|
|
tree-sitter-heex.workspace = true
|
|
tree-sitter-html.workspace = true
|
|
tree-sitter-json.workspace = true
|
|
tree-sitter-md.workspace = true
|
|
tree-sitter-python.workspace = true
|
|
tree-sitter-ruby.workspace = true
|
|
tree-sitter-c.workspace = true
|
|
tree-sitter-rust.workspace = true
|
|
tree-sitter-typescript.workspace = true
|
|
toml.workspace = true
|
|
unindent.workspace = true
|
|
util = { workspace = true, features = ["test-support"] }
|
|
zlog.workspace = true
|
|
criterion.workspace = true
|
|
theme_settings.workspace = true
|
|
|
|
[[bench]]
|
|
name = "highlight_map"
|
|
harness = false
|
|
|
|
[package.metadata.cargo-machete]
|
|
ignored = ["tracing"]
|