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(
|
||||
"Editor",
|
||||
Some(size(px(1200.), px(960.))),
|
||||
Some(size(px(1200.), px(750.))),
|
||||
|window, cx| cx.new(|cx| Example::new(window, cx)),
|
||||
cx,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1085,7 +1085,7 @@ impl Element for TextElement {
|
|||
|
||||
let hover_definition_hitbox = self.layout_hover_definition_hitbox(state, window, cx);
|
||||
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 {
|
||||
bounds,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use gpui::{
|
||||
point, px, Context, EntityInputHandler as _, Hsla, Path, PathBuilder, Pixels, SharedString,
|
||||
TextRun, TextStyle, Window,
|
||||
point, px, Bounds, Context, EntityInputHandler as _, Hsla, Path, PathBuilder, Pixels,
|
||||
SharedString, TextRun, TextStyle, Window,
|
||||
};
|
||||
use ropey::RopeSlice;
|
||||
|
||||
|
|
@ -104,6 +104,7 @@ impl TextElement {
|
|||
pub(super) fn layout_indent_guides(
|
||||
&self,
|
||||
state: &InputState,
|
||||
bounds: &Bounds<Pixels>,
|
||||
last_layout: &LastLayout,
|
||||
text_style: &TextStyle,
|
||||
window: &mut Window,
|
||||
|
|
@ -119,8 +120,7 @@ impl TextElement {
|
|||
let line_height = last_layout.line_height;
|
||||
let visible_range = last_layout.visible_range.clone();
|
||||
let mut builder = PathBuilder::stroke(px(1.));
|
||||
let mut offset_y =
|
||||
last_layout.visible_top + state.scroll_handle.offset().y + (line_height * 2 - px(3.5));
|
||||
let mut offset_y = last_layout.visible_top;
|
||||
let mut last_indents = vec![];
|
||||
for ix in visible_range {
|
||||
let line = state.text.slice_line(ix);
|
||||
|
|
@ -154,6 +154,7 @@ impl TextElement {
|
|||
last_indents = current_indents;
|
||||
}
|
||||
|
||||
builder.translate(bounds.origin);
|
||||
let path = builder.build().unwrap();
|
||||
Some(path)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue