editor: Fix indent guides render position. (#1524)
This commit is contained in:
parent
998a5fd922
commit
4b3fb51fb8
3 changed files with 7 additions and 6 deletions
|
|
@ -1041,7 +1041,7 @@ fn main() {
|
||||||
|
|
||||||
story::create_new_window_with_size(
|
story::create_new_window_with_size(
|
||||||
"Editor",
|
"Editor",
|
||||||
Some(size(px(1200.), px(960.))),
|
Some(size(px(1200.), px(750.))),
|
||||||
|window, cx| cx.new(|cx| Example::new(window, cx)),
|
|window, cx| cx.new(|cx| Example::new(window, cx)),
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1085,7 +1085,7 @@ impl Element for TextElement {
|
||||||
|
|
||||||
let hover_definition_hitbox = self.layout_hover_definition_hitbox(state, window, cx);
|
let hover_definition_hitbox = self.layout_hover_definition_hitbox(state, window, cx);
|
||||||
let indent_guides_path =
|
let indent_guides_path =
|
||||||
self.layout_indent_guides(state, &last_layout, &text_style, window);
|
self.layout_indent_guides(state, &bounds, &last_layout, &text_style, window);
|
||||||
|
|
||||||
PrepaintState {
|
PrepaintState {
|
||||||
bounds,
|
bounds,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use gpui::{
|
use gpui::{
|
||||||
point, px, Context, EntityInputHandler as _, Hsla, Path, PathBuilder, Pixels, SharedString,
|
point, px, Bounds, Context, EntityInputHandler as _, Hsla, Path, PathBuilder, Pixels,
|
||||||
TextRun, TextStyle, Window,
|
SharedString, TextRun, TextStyle, Window,
|
||||||
};
|
};
|
||||||
use ropey::RopeSlice;
|
use ropey::RopeSlice;
|
||||||
|
|
||||||
|
|
@ -104,6 +104,7 @@ impl TextElement {
|
||||||
pub(super) fn layout_indent_guides(
|
pub(super) fn layout_indent_guides(
|
||||||
&self,
|
&self,
|
||||||
state: &InputState,
|
state: &InputState,
|
||||||
|
bounds: &Bounds<Pixels>,
|
||||||
last_layout: &LastLayout,
|
last_layout: &LastLayout,
|
||||||
text_style: &TextStyle,
|
text_style: &TextStyle,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
|
|
@ -119,8 +120,7 @@ impl TextElement {
|
||||||
let line_height = last_layout.line_height;
|
let line_height = last_layout.line_height;
|
||||||
let visible_range = last_layout.visible_range.clone();
|
let visible_range = last_layout.visible_range.clone();
|
||||||
let mut builder = PathBuilder::stroke(px(1.));
|
let mut builder = PathBuilder::stroke(px(1.));
|
||||||
let mut offset_y =
|
let mut offset_y = last_layout.visible_top;
|
||||||
last_layout.visible_top + state.scroll_handle.offset().y + (line_height * 2 - px(3.5));
|
|
||||||
let mut last_indents = vec![];
|
let mut last_indents = vec![];
|
||||||
for ix in visible_range {
|
for ix in visible_range {
|
||||||
let line = state.text.slice_line(ix);
|
let line = state.text.slice_line(ix);
|
||||||
|
|
@ -154,6 +154,7 @@ impl TextElement {
|
||||||
last_indents = current_indents;
|
last_indents = current_indents;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
builder.translate(bounds.origin);
|
||||||
let path = builder.build().unwrap();
|
let path = builder.build().unwrap();
|
||||||
Some(path)
|
Some(path)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue