Fix review comments

pull/6118/merge^2
SoraTenshi 11 months ago
parent 67bbd65d6c
commit c9dee78748

@ -248,8 +248,6 @@ pub fn render_sticky_context(
for node in context { for node in context {
surface.clear_with(context_area, context_style); surface.clear_with(context_area, context_style);
let mut view_offset = view.offset;
if let Some(indicator) = node.indicator.as_deref() { if let Some(indicator) = node.indicator.as_deref() {
// set the indicator // set the indicator
surface.set_stringn( surface.set_stringn(
@ -263,25 +261,23 @@ pub fn render_sticky_context(
} }
let node_start = text.byte_to_char(node.byte_range.start); let node_start = text.byte_to_char(node.byte_range.start);
view_offset.anchor = node_start;
let first_node_line = text.line(text.char_to_line(node_start)); let first_node_line = text.line(text.char_to_line(node_start));
let first_node_width = first_node_line.len_chars();
// calculate the reserved space for the basic render // subtract 1 to handle indexes
let start_node_width = first_node_width.saturating_sub( let mut first_node_line_end = first_node_line.len_chars().saturating_sub(1);
first_node_line
// trim trailing whitespace / newline
first_node_line_end -= first_node_line
.chars() .chars()
.reversed() .reversed()
.position(|c| !c.is_whitespace()) .position(|c| !c.is_whitespace())
.unwrap_or(1), .unwrap_or(0);
);
#[allow(deprecated)] #[allow(deprecated)]
let Position { let Position {
row: _, row: _,
col: start_vis_offset, col: first_node_line_end,
} = visual_coords_at_pos(first_node_line, start_node_width, doc.tab_width()); } = visual_coords_at_pos(first_node_line, first_node_line_end, doc.tab_width());
// get the highlighting of the basic capture // get the highlighting of the basic capture
let highlights = EditorView::doc_syntax_highlights(doc, node_start, 1, theme); let highlights = EditorView::doc_syntax_highlights(doc, node_start, 1, theme);
@ -290,13 +286,7 @@ pub fn render_sticky_context(
// Limit scope of borrowed surface // Limit scope of borrowed surface
{ {
let mut renderer = TextRenderer::new( let mut renderer = TextRenderer::new(surface, doc, theme, 0, context_area);
surface,
doc,
theme,
view.offset.horizontal_offset,
context_area,
);
// create the formatting for the basic node render // create the formatting for the basic node render
let mut formatting = doc.text_format(context_area.width, Some(theme)); let mut formatting = doc.text_format(context_area.width, Some(theme));
@ -316,7 +306,7 @@ pub fn render_sticky_context(
&mut [], &mut [],
&mut [], &mut [],
); );
offset_area.x += start_vis_offset as u16; offset_area.x += first_node_line_end as u16;
} }
if node.has_context_end { if node.has_context_end {

Loading…
Cancel
Save