ZIm/crates
Jason Lee 706f7be5e7
gpui: Add line_clamp to truncate text after a specified number of lines (#23058)
Release Notes:

- N/A

Add this feature for some case we need keep 2 or 3 lines, but truncate.
For example the blog post summary.

- Added `line_clamp` method.
    Ref: https://tailwindcss.com/docs/line-clamp


## Break changes:

- Renamed `gpui::Truncate` to `gpui::TextOverflow` to match
[CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow).
- Update `truncate` style method to match [Tailwind
CSS](https://tailwindcss.com/docs/text-overflow) behavior:

    ```css
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    ```
<img width="538" alt="image"
src="https://github.com/user-attachments/assets/c69c4213-eac9-4087-9daa-ce7afe18c758"
/>


## Show case

<img width="816" alt="image"
src="https://github.com/user-attachments/assets/e0660290-8042-4954-b93c-c729d609484a"
/>

![CleanShot 2025-01-13 at 17 22
05](https://github.com/user-attachments/assets/38644892-79fe-4254-af9e-88c1349561bd)

## Describe changes

The [second
commit](6b41c2772f)
for make sure text layout to match with the line clamp. Before this
change, they may wrap many lines in sometimes. And I also make
line_clamp default to 1 if we used `truncate` to ensure no wrap.

> TODO: There is still a tiny detail that is not easy to fix. This
problem only occurs in the case of certain long words. I will think
about how to improve it later. At present, this has some flaws but does
not affect the use.
2025-01-29 22:14:24 +02:00
..
activity_indicator Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
anthropic anthropic: Don't bail out on unknown model ID (#23782) 2025-01-28 10:56:05 -05:00
assets Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
assistant Fix window double borrows (#23739) 2025-01-27 21:56:29 +00:00
assistant2 assistant2: Tweak the settings UI (#23845) 2025-01-29 16:20:09 -03:00
assistant_context_editor Fix window double borrows (#23739) 2025-01-27 21:56:29 +00:00
assistant_settings Add DeepSeek support (#23551) 2025-01-27 13:40:59 -05:00
assistant_slash_command Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
assistant_slash_commands Omit gitignored files from context file picker (#23777) 2025-01-28 11:40:42 -03:00
assistant_tool Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
assistant_tools Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
audio Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
auto_update Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
auto_update_ui Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
breadcrumbs Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
call Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
channel Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
cli Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
client Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
clock chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
collab collab: Add internal POST /snowflake/events endpoint (#23842) 2025-01-29 16:33:48 +00:00
collab_ui Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
collections chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
command_palette Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
command_palette_hooks Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
context_server Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
context_server_settings Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
copilot Revert "inline completion: Add syntax highlighting for edit prediction (#23361)" (#23829) 2025-01-29 11:32:18 +01:00
db Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
deepseek Add DeepSeek support (#23551) 2025-01-27 13:40:59 -05:00
diagnostics Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
docs_preprocessor Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
editor Revert "inline completion: Add syntax highlighting for edit prediction (#23361)" (#23829) 2025-01-29 11:32:18 +01:00
evals Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
extension Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
extension_api chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
extension_cli chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
extension_host Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
extensions_ui Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
feature_flags edit prediction: Hide rate completions modal behind feature flag (#23597) 2025-01-28 12:27:09 +01:00
feedback Prompt users to use Discussions for feature requests (#23821) 2025-01-29 06:48:07 +00:00
file_finder Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
file_icons Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
fireworks chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
fs Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
fsevent chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
fuzzy chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
git Fix unnecessarily large edits emitted from multi buffer on diff recalculation (#23753) 2025-01-27 18:11:15 -08:00
git_hosting_providers Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
git_ui Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
go_to_line Fix window double borrows (#23739) 2025-01-27 21:56:29 +00:00
google_ai chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
gpui gpui: Add line_clamp to truncate text after a specified number of lines (#23058) 2025-01-29 22:14:24 +02:00
gpui_macros Revert "project: Fine-grained language server management" (#23804) 2025-01-28 21:38:06 +00:00
html_to_markdown Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
http_client chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
image_viewer Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
indexed_docs Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
inline_completion Revert "inline completion: Add syntax highlighting for edit prediction (#23361)" (#23829) 2025-01-29 11:32:18 +01:00
inline_completion_button edit prediction: Hide rate completions modal behind feature flag (#23597) 2025-01-28 12:27:09 +01:00
install_cli Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
journal Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
language Revert "inline completion: Add syntax highlighting for edit prediction (#23361)" (#23829) 2025-01-29 11:32:18 +01:00
language_extension Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
language_model Add DeepSeek support (#23551) 2025-01-27 13:40:59 -05:00
language_model_selector assistant: Preserve selection focus in the model selector (#23713) 2025-01-27 12:29:08 -03:00
language_models gpui: Add line_clamp to truncate text after a specified number of lines (#23058) 2025-01-29 22:14:24 +02:00
language_selector Refactor to use SharedString in more places (#23813) 2025-01-28 19:04:21 -05:00
language_tools Refactor to use SharedString in more places (#23813) 2025-01-28 19:04:21 -05:00
languages Revert "project: Fine-grained language server management" (#23804) 2025-01-28 21:38:06 +00:00
livekit_client Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
livekit_client_macos Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
livekit_server chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
lmstudio Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
lsp Revert "project: Fine-grained language server management" (#23804) 2025-01-28 21:38:06 +00:00
markdown Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
markdown_preview Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
media chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
menu chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
multi_buffer Allow buffer search to search deleted hunks (#23632) 2025-01-28 21:48:16 +00:00
node_runtime chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
notifications Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
ollama Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
open_ai openai: Add back O1-Preview (#23715) 2025-01-27 14:44:12 +00:00
outline Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
outline_panel Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
paths Add auto-completion support for snippet files (#23698) 2025-01-27 12:32:22 +01:00
picker Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
prettier Revert "project: Fine-grained language server management" (#23804) 2025-01-28 21:38:06 +00:00
project Refactor to use SharedString in more places (#23813) 2025-01-28 19:04:21 -05:00
project_panel project_panel: Add precise drag-and-drop for files onto folded directories (#22983) 2025-01-28 10:42:10 +02:00
project_symbols Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
prompt_library Refactor to use SharedString in more places (#23813) 2025-01-28 19:04:21 -05:00
proto Revert "project: Fine-grained language server management" (#23804) 2025-01-28 21:38:06 +00:00
recent_projects Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
refineable Revert "project: Fine-grained language server management" (#23804) 2025-01-28 21:38:06 +00:00
release_channel Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
remote Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
remote_server Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
repl gpui: Add line_clamp to truncate text after a specified number of lines (#23058) 2025-01-29 22:14:24 +02:00
reqwest_client Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
rich_text Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
rope Rework go to line infrastructure (#23654) 2025-01-25 19:24:19 +00:00
rpc Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
search Fix window double borrows (#23739) 2025-01-27 21:56:29 +00:00
semantic_index Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
semantic_version chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
session Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
settings Show settings file errors on startup (#23817) 2025-01-29 07:05:33 +00:00
settings_ui Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
snippet Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
snippet_provider snippets: Fix snippets not updating while containing comments (#23755) 2025-01-28 10:37:48 +01:00
snippets_ui Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
sqlez Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
sqlez_macros chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
story Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
storybook Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
streaming_diff chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
sum_tree Rework diff rendering to allow putting the cursor into deleted text, soft-wrapping and scrolling deleted text correctly (#22994) 2025-01-24 14:18:22 -07:00
supermaven Revert "inline completion: Add syntax highlighting for edit prediction (#23361)" (#23829) 2025-01-29 11:32:18 +01:00
supermaven_api Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
tab_switcher Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
task Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
tasks_ui Fix missed renames in #22632 (#23688) 2025-01-26 23:37:34 +00:00
telemetry chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
telemetry_events chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
terminal Sanitize another pair of brackets when hovering over a path in the terminal (#23776) 2025-01-28 16:03:48 +02:00
terminal_view gpui: Add line_clamp to truncate text after a specified number of lines (#23058) 2025-01-29 22:14:24 +02:00
text Fix unnecessarily large edits emitted from multi buffer on diff recalculation (#23753) 2025-01-27 18:11:15 -08:00
theme Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
theme_extension Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
theme_importer Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
theme_selector Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
time_format chore: Use workspace fields for edition and publish (#23291) 2025-01-17 17:39:22 +01:00
title_bar Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
toolchain_selector Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
ui Revert "gpui & ui: Use shader for dashed dividers" (#23850) 2025-01-29 19:19:20 +00:00
ui_input Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
ui_macros Revert "project: Fine-grained language server management" (#23804) 2025-01-28 21:38:06 +00:00
util Canonicalize paths when running tests (#23655) 2025-01-26 14:56:07 +08:00
vcs_menu Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
vim Add comment explaining why AddSurrounds target is not deserializable (#23820) 2025-01-29 06:18:56 +00:00
vim_mode_setting Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
welcome Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
workspace Revert "gpui & ui: Use shader for dashed dividers" (#23850) 2025-01-29 19:19:20 +00:00
worktree Omit gitignored files from context file picker (#23777) 2025-01-28 11:40:42 -03:00
zed Bump Zed to v0.173 (#23843) 2025-01-29 11:55:51 -05:00
zed_actions Eliminate GPUI View, ViewContext, and WindowContext types (#22632) 2025-01-26 03:02:45 +00:00
zed_predict_tos Remove more references to 'model' in GPUI APIs (#23693) 2025-01-27 04:00:27 +00:00
zeta zeta: Send staff edit predictions through Cloudflare Workers (#23847) 2025-01-29 13:22:16 -05:00