editor: Wrap placeholder if text overflows (#37919)

This fixes an issue where long placeholders would be cut off, e.g. in a
Claude Code thread:

<img width="387" height="115" alt="image"
src="https://github.com/user-attachments/assets/831a54aa-cf2b-4d87-af86-e368a5936f6b"
/>

Now:

<img width="354" height="115" alt="image"
src="https://github.com/user-attachments/assets/e5df5e05-0869-4db2-8dee-38611263191c"
/>


Most of the changes in this PR are caused by us requiring `&mut Window`
in `set_placeholder_text`.

Release Notes:

- Fixed an issue where placeholders inside editors would not wrap

---------

Co-authored-by: Agus Zubiaga <agus@zed.dev>
This commit is contained in:
Bennet Bo Fenner
2025-09-10 15:38:19 +00:00
committed by GitHub
co-authored by Agus Zubiaga
parent fb3c991112
commit acb3406eb8
36 changed files with 143 additions and 97 deletions
+2 -2
View File
@@ -803,12 +803,12 @@ impl ConfigureMode {
pub(super) fn new(window: &mut Window, cx: &mut App) -> Entity<Self> {
let program = cx.new(|cx| Editor::single_line(window, cx));
program.update(cx, |this, cx| {
this.set_placeholder_text("ENV=Zed ~/bin/program --option", cx);
this.set_placeholder_text("ENV=Zed ~/bin/program --option", window, cx);
});
let cwd = cx.new(|cx| Editor::single_line(window, cx));
cwd.update(cx, |this, cx| {
this.set_placeholder_text("Ex: $ZED_WORKTREE_ROOT", cx);
this.set_placeholder_text("Ex: $ZED_WORKTREE_ROOT", window, cx);
});
cx.new(|_| Self {
@@ -219,7 +219,7 @@ impl BreakpointList {
});
self.input.update(cx, |this, cx| {
this.set_placeholder_text(placeholder, cx);
this.set_placeholder_text(placeholder, window, cx);
this.set_read_only(is_exception_breakpoint);
this.set_text(active_value.as_deref().unwrap_or(""), window, cx);
});
@@ -83,7 +83,7 @@ impl Console {
let this = cx.weak_entity();
let query_bar = cx.new(|cx| {
let mut editor = Editor::single_line(window, cx);
editor.set_placeholder_text("Evaluate an expression", cx);
editor.set_placeholder_text("Evaluate an expression", window, cx);
editor.set_use_autoclose(false);
editor.set_show_gutter(false, cx);
editor.set_show_wrap_guides(false, cx);
@@ -428,14 +428,14 @@ impl MemoryView {
if !self.is_writing_memory {
self.query_editor.update(cx, |this, cx| {
this.clear(window, cx);
this.set_placeholder_text("Write to Selected Memory Range", cx);
this.set_placeholder_text("Write to Selected Memory Range", window, cx);
});
self.is_writing_memory = true;
self.query_editor.focus_handle(cx).focus(window);
} else {
self.query_editor.update(cx, |this, cx| {
this.clear(window, cx);
this.set_placeholder_text("Go to Memory Address / Expression", cx);
this.set_placeholder_text("Go to Memory Address / Expression", window, cx);
});
self.is_writing_memory = false;
}