Highlight the selected line when typing in the go to line dialog
This commit is contained in:
@@ -263,6 +263,20 @@ impl EditorElement {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(highlighted_row) = layout.highlighted_row {
|
||||
let origin = vec2f(
|
||||
bounds.origin_x(),
|
||||
bounds.origin_y() + (layout.line_height * highlighted_row as f32) - scroll_top,
|
||||
);
|
||||
let size = vec2f(bounds.width(), layout.line_height);
|
||||
cx.scene.push_quad(Quad {
|
||||
bounds: RectF::new(origin, size),
|
||||
background: Some(style.highlighted_line_background),
|
||||
border: Border::default(),
|
||||
corner_radius: 0.,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Draw block backgrounds
|
||||
@@ -729,7 +743,9 @@ impl Element for EditorElement {
|
||||
|
||||
let mut selections = HashMap::new();
|
||||
let mut active_rows = BTreeMap::new();
|
||||
let mut highlighted_row = None;
|
||||
self.update_view(cx.app, |view, cx| {
|
||||
highlighted_row = view.highlighted_row();
|
||||
for selection_set_id in view.active_selection_sets(cx).collect::<Vec<_>>() {
|
||||
let mut set = Vec::new();
|
||||
for selection in view.selections_in_range(
|
||||
@@ -786,6 +802,7 @@ impl Element for EditorElement {
|
||||
snapshot,
|
||||
style: self.settings.style.clone(),
|
||||
active_rows,
|
||||
highlighted_row,
|
||||
line_layouts,
|
||||
line_number_layouts,
|
||||
block_layouts,
|
||||
@@ -915,6 +932,7 @@ pub struct LayoutState {
|
||||
style: EditorStyle,
|
||||
snapshot: Snapshot,
|
||||
active_rows: BTreeMap<u32, bool>,
|
||||
highlighted_row: Option<u32>,
|
||||
line_layouts: Vec<text_layout::Line>,
|
||||
line_number_layouts: Vec<Option<text_layout::Line>>,
|
||||
block_layouts: Vec<(Range<u32>, BlockStyle)>,
|
||||
|
||||
@@ -351,6 +351,7 @@ pub struct Editor {
|
||||
blinking_paused: bool,
|
||||
mode: EditorMode,
|
||||
placeholder_text: Option<Arc<str>>,
|
||||
highlighted_row: Option<u32>,
|
||||
}
|
||||
|
||||
pub struct Snapshot {
|
||||
@@ -485,6 +486,7 @@ impl Editor {
|
||||
blinking_paused: false,
|
||||
mode: EditorMode::Full,
|
||||
placeholder_text: None,
|
||||
highlighted_row: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3248,15 +3250,19 @@ impl Editor {
|
||||
.text()
|
||||
}
|
||||
|
||||
// pub fn font_size(&self) -> f32 {
|
||||
// self.settings.font_size
|
||||
// }
|
||||
|
||||
pub fn set_wrap_width(&self, width: f32, cx: &mut MutableAppContext) -> bool {
|
||||
self.display_map
|
||||
.update(cx, |map, cx| map.set_wrap_width(Some(width), cx))
|
||||
}
|
||||
|
||||
pub fn set_highlighted_row(&mut self, row: Option<u32>) {
|
||||
self.highlighted_row = row;
|
||||
}
|
||||
|
||||
pub fn highlighted_row(&mut self) -> Option<u32> {
|
||||
self.highlighted_row
|
||||
}
|
||||
|
||||
fn next_blink_epoch(&mut self) -> usize {
|
||||
self.blink_epoch += 1;
|
||||
self.blink_epoch
|
||||
@@ -3426,6 +3432,7 @@ impl EditorSettings {
|
||||
background: Default::default(),
|
||||
gutter_background: Default::default(),
|
||||
active_line_background: Default::default(),
|
||||
highlighted_line_background: Default::default(),
|
||||
line_number: Default::default(),
|
||||
line_number_active: Default::default(),
|
||||
selection: Default::default(),
|
||||
|
||||
Reference in New Issue
Block a user