zed/crates/language/src
Vitaly Slobodin a6653f0d95
language: Respect combined injection sub-ranges for language queries (#48522)
Follow-up to https://github.com/zed-industries/zed/pull/41111.

PR #41111 introduced combined injection handling, but cursor language
queries still relied on layer range selection alone. For combined
injections this can surface a language from the outer combined layer
even when the cursor is outside that language's actual included
sub-range. So, we just need to add sub-range filtering based on
anchor-aware boundary checks in the same way we did in the previous PR.
That means: apply it in `Buffer::language_at`,
`Buffer::languages_at`, and `BufferSnapshot::language_scope_at`. All
places that rely on the described behavior.

I also added some additional test cases for the `HTML+ERB` lang to
verify language resolution for HTML and Ruby positions.
Thank you!

Closes https://github.com/zed-industries/zed/issues/48358

Release Notes:

- Respect combined injection sub-ranges for language queries
2026-02-13 12:06:34 +01:00
..
buffer multi_buffer: Optimize a bunch of things (#48519) 2026-02-05 20:10:02 +00:00
syntax_map Improve performance when detecting JSX auto close (#48622) 2026-02-10 20:46:28 +05:30
buffer.rs language: Respect combined injection sub-ranges for language queries (#48522) 2026-02-13 12:06:34 +01:00
buffer_tests.rs language: Respect combined injection sub-ranges for language queries (#48522) 2026-02-13 12:06:34 +01:00
diagnostic_set.rs diagnostics: Reduce cloning of DiagnosticEntry (#39193) 2025-09-30 11:41:49 +00:00
highlight_map.rs rust: Nicer snippet completions (#43891) 2025-12-01 12:19:00 -03:00
language.rs languages: Fix local path of JSON and YAML schemas (#44794) 2026-02-12 04:50:54 +00:00
language_registry.rs json_schema_store: Include available LSP adapters in settings schema (#46766) 2026-02-12 09:58:38 -05:00
language_settings.rs Support LSP document symbols in breadcrumbs and outline UI (#48780) 2026-02-11 21:30:03 +02:00
manifest.rs Represent relative paths using a dedicated, separator-agnostic type (#38744) 2025-09-24 18:57:33 -04:00
outline.rs Add experimental LSP-based context retrieval system for edit prediction (#44036) 2025-12-04 12:48:39 -08:00
proto.rs Improve support for multiple registrations of textDocument/diagnostic (#43703) 2025-12-03 20:47:43 +02:00
syntax_map.rs ztracing: Annotate more callsites that invoke TreeSitter (#47522) 2026-02-11 11:24:04 +00:00
task_context.rs Revert " Add vim/emacs modeline support " (#47479) 2026-01-23 15:24:37 +00:00
text_diff.rs Add initial support for edit predictions via Ollama (#48233) 2026-02-04 01:33:12 +00:00
toolchain.rs Revert "Allow always_allow patterns for Nushell, Elvish, and Rc shells" (#48050) 2026-01-30 21:26:13 +00:00