ZIm/crates/language/src
Kirill Bulatov 75c5344754
Fix completion labels becoming overly large due to LSP completion items with newlines (#23407)
Reworks https://github.com/zed-industries/zed/pull/23030 and
https://github.com/zed-industries/zed/pull/15087
Closes https://github.com/zed-industries/zed/issues/23352
Closes https://github.com/zed-industries/zed/issues/23310 

Zed's completion items use `label` from LSP completion items as a base
to show in the list:
d290da7dac/crates/project/src/lsp_store.rs (L4371-L4374)

Besides that, certain language plugins append `detail` or
`label_details.description` as a suffix:
d290da7dac/crates/languages/src/vtsls.rs (L178-L188)

Either of these 3 properties may return `\n` (or multiple) in it,
spoiling Zed's completion menu, which uses `UniformList` to render those
items: a uniform list uses common, minimum possible height for each
element, and `\n` bloats that overly.

Good approach would be to use something else:
https://github.com/zed-industries/zed/issues/21403 but that has its own
drawbacks and relatively hard to use instead (?).

We could follow VSCode's approach and move away all but `label` from
`CodeLabel.text` to the side, where the documentation is, but that does
not solve the issue with `details` having newlines.

So, for now, sanitize all labels and remove any newlines from them. If
newlines are found, also replace whitespace sequences if there's more
than 1 in a row.

Later, this approach can be improved similarly to how Helix and Zed's
inline completions do: rendering a "ghost" text, showing the
completion's edit applied to the editor.

Release Notes:

- Fixed completion labels becoming overly large due to LSP completion
items with newlines
2025-01-21 17:55:41 +02:00
..
syntax_map Use standard injection.language and injection.content captures (#22268) 2025-01-07 18:17:49 +00:00
buffer.rs Make language registry optional in parse_markdown (#23221) 2025-01-16 03:56:46 -07:00
buffer_tests.rs Use standard injection.language and injection.content captures (#22268) 2025-01-07 18:17:49 +00:00
diagnostic_set.rs Add validation in LspCommand::to_lsp + check for inverted ranges (#22731) 2025-01-06 22:00:36 +00:00
highlight_map.rs Docs for indent_size_for_line and co 2024-01-09 20:50:34 +01:00
language.rs Fix completion labels becoming overly large due to LSP completion items with newlines (#23407) 2025-01-21 17:55:41 +02:00
language_registry.rs Add textobjects queries (#20924) 2024-12-03 10:37:01 -07:00
language_settings.rs settings: Rename 'zeta' to 'zed' (#23174) 2025-01-15 10:53:30 +00:00
markdown.rs Make language registry optional in parse_markdown (#23221) 2025-01-16 03:56:46 -07:00
outline.rs Improve StringMatchCandidate::new interface (#22011) 2024-12-14 13:35:36 -07:00
proto.rs lsp: Track completion triggers for each language separately (#20471) 2024-11-10 10:29:10 +01:00
syntax_map.rs Expand diagnostic excerpts using heuristics on syntactic information from TreeSitter (#21942) 2024-12-20 22:42:18 +00:00
task_context.rs tasks: Add ability to query active toolchains for languages (#20667) 2024-11-14 14:37:37 +01:00
toolchain.rs toolchains: Do not use as_json representation for PartialEq (#21682) 2024-12-07 14:52:55 +01:00