ZIm/crates/language/src
smit 1f52aab7c7
buffer: Fix panic when multi-byte character is used in languages like Swift (#25739)
Closes #25471

In languages like Swift, names can be concatinated in form like `class
Example: UI`, notice here `Example` and `:` are two different words.
Before, `name_ranges`translation of above text would look like:

```
"class" -> [0..5]
" Example" -> [5..13] (Spaces are intentional)
"e:" -> [12..14] (This is incorrect, and should be ":" -> [13..14])
" UI" -> [14..16]
```

Because this translation does not account for concatinated words, this
might affect queries, but most importantly this panics when multi-byte
character (`ф`) is used in place of `e`, as it then tries to access
index which lies inside that multi-byte. For example, it panics on
`class Examplф: UI`.

---

This PR fixes this by handing concatinated words when calculating
`name_ranges`.

Now, the corrected ranges will look like:

```
"class" -> [0..5]
" Example" -> [5..13]
":" -> [13..14] (Now it's correct)
" UI" -> [14..16]
```

and for multi-byte character

```
"class" -> [0..5]
" Examplф" -> [5..14] (Notice ф takes two bytes)
":" -> [14..15]
" UI" -> [15..17]
```

This way, it no longer tries to access a previous index, preventing a
panic when that index contains a multi-byte character.

Release Notes:

- Fixed a panic when Cyrillic characters are used in languages like
Swift.
2025-02-27 16:27:07 +05:30
..
syntax_map Bump Tree-sitter for bug fixes affecting YAML parser loaded via WASM (#25054) 2025-02-17 21:29:27 -08:00
buffer.rs buffer: Fix panic when multi-byte character is used in languages like Swift (#25739) 2025-02-27 16:27:07 +05:30
buffer_tests.rs Fix relative indentation when pasting content copied from outside Zed (#25300) 2025-02-21 01:25:33 +00:00
diagnostic_set.rs zeta: Send up diagnostics with prediction requests (#24384) 2025-02-06 18:07:26 +00:00
highlight_map.rs Docs for indent_size_for_line and co 2024-01-09 20:50:34 +01:00
language.rs html: Open extra newline between opening and closing HTML tags (#25130) 2025-02-20 01:09:19 -05:00
language_registry.rs cx.background_executor().spawn(...) -> cx.background_spawn(...) (#25103) 2025-02-18 20:30:33 +00:00
language_settings.rs language_settings: Add auto alias for subtle edit prediction mode (#25686) 2025-02-26 22:06:17 +00:00
outline.rs Fix panic when outline items have no name (#24574) 2025-02-10 18:50:26 +00:00
proto.rs Fix #24081 - lsp diagnostic code type conversion (#24347) 2025-02-05 21:23:46 -06:00
syntax_map.rs Revert "file_finder: Remove common segments of long paths in search results (#25049)" (#25163) 2025-02-19 15:32:29 +00:00
task_context.rs Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
text_diff.rs Use line-based and word-based diff when reloading and formatting buffers (#25129) 2025-02-20 00:56:01 +00:00
toolchain.rs Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00