Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix block cursor obscuring placeholder text and editor text in some cases #18114

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions crates/editor/src/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,8 +1012,20 @@ impl EditorElement {
block_width = em_width;
}
let block_text = if let CursorShape::Block = selection.cursor_shape {
snapshot.display_chars_at(cursor_position).next().and_then(
|(character, _)| {
snapshot
.display_chars_at(cursor_position)
.next()
.or_else(|| {
if cursor_column == 0 {
snapshot
.placeholder_text()
.and_then(|s| s.chars().next())
.map(|c| (c, cursor_position))
} else {
None
}
})
.and_then(|(character, _)| {
let text = if character == '\n' {
SharedString::from(" ")
} else {
Expand All @@ -1035,15 +1047,14 @@ impl EditorElement {
&[TextRun {
len,
font,
color: self.style.background,
color: cx.theme().colors().editor_background,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here editor_background may give you a value like hsla(0.,0.,0.,0.) in some themes. I assume this will make the text vanish, so we should have some sort of check to ensure this is a color that is at least partially opaque.

background_color: None,
strikethrough: None,
underline: None,
}],
)
.log_err()
},
)
})
} else {
None
};
Expand Down
Loading