When renaming, fade out the old name and select all

This commit is contained in:
Nathan Sobo
2022-03-10 14:55:31 -07:00
parent e6b1fea117
commit 3968b37e26
7 changed files with 70 additions and 48 deletions
+4 -10
View File
@@ -4393,20 +4393,14 @@ impl Editor {
editor
.buffer
.update(cx, |buffer, cx| buffer.edit([0..0], &old_name, cx));
editor.select_ranges(
[tail_offset_in_rename_range..cursor_offset_in_rename_range],
None,
cx,
);
editor.select_all(&SelectAll, cx);
editor
});
this.highlight_text::<Rename>(
vec![range.clone()],
HighlightStyle {
color: Color::transparent_black(),
font_properties: todo!(),
underline: todo!(),
fade_out: todo!(),
fade_out: Some(style.rename_fade),
..Default::default()
},
cx,
);
@@ -4500,7 +4494,7 @@ impl Editor {
fn take_rename(&mut self, cx: &mut ViewContext<Self>) -> Option<RenameState> {
let rename = self.pending_rename.take()?;
self.remove_blocks([rename.block_id].into_iter().collect(), cx);
self.clear_background_highlights::<Rename>(cx);
self.clear_text_highlights::<Rename>(cx);
let editor = rename.editor.read(cx);
let snapshot = self.buffer.read(cx).snapshot(cx);
+22 -18
View File
@@ -606,30 +606,34 @@ impl EditorElement {
} else {
let style = &self.style;
let chunks = snapshot.chunks(rows.clone(), true).map(|chunk| {
let mut highlight_style = HighlightStyle {
color: style.text.color,
font_properties: style.text.font_properties,
..Default::default()
};
if let Some(syntax_highlight_style) = chunk
let mut highlight_style = chunk
.syntax_highlight_id
.and_then(|id| id.style(&style.syntax))
{
highlight_style.highlight(syntax_highlight_style);
}
.and_then(|id| id.style(&style.syntax));
if let Some(style) = chunk.highlight_style {
highlight_style.highlight(style);
if let Some(chunk_highlight) = chunk.highlight_style {
if let Some(highlight_style) = highlight_style.as_mut() {
highlight_style.highlight(chunk_highlight);
} else {
highlight_style = Some(chunk_highlight);
}
}
if let Some(severity) = chunk.diagnostic {
let diagnostic_style = super::diagnostic_style(severity, true, style);
highlight_style.underline = Some(Underline {
color: diagnostic_style.message.text.color,
thickness: 1.0.into(),
squiggly: true,
});
let diagnostic_highlight = HighlightStyle {
underline: Some(Underline {
color: diagnostic_style.message.text.color,
thickness: 1.0.into(),
squiggly: true,
}),
..Default::default()
};
if let Some(highlight_style) = highlight_style.as_mut() {
highlight_style.highlight(diagnostic_highlight);
} else {
highlight_style = Some(diagnostic_highlight);
}
}
(chunk.text, highlight_style)