Fix block cursor using placeholder text even when it's not displayed (#32766)

The condition for displaying the first char of the placeholder text in
the block cursor was `cursor_column == 0`. This meant that it was
displayed on the first column even when the placeholder text is not
being displayed. Instead this now shows it only when
`snapshot.is_empty()` - the same condition used to determine whether to
show placeholder text.

In the case of vim mode + agent panel message editor, this meant that if
you did `shift-enter` to make a newline and then `escape` to enter
normal mode, the block cursor would show `M` inside it as that's the
first character of the placeholder text "Message the agent - @ to
include context"

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-06-15 13:09:18 -06:00 committed by GitHub
parent f052a9e28c
commit c0717bc613
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1559,7 +1559,7 @@ impl EditorElement {
snapshot
.grapheme_at(cursor_position)
.or_else(|| {
if cursor_column == 0 {
if snapshot.is_empty() {
snapshot.placeholder_text().and_then(|s| {
s.graphemes(true).next().map(|s| s.to_string().into())
})