mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 21:32:40 +00:00
Fix alignment of blocks adjacent to other blocks
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
ee693a8d2b
commit
5ae46709b0
2 changed files with 9 additions and 8 deletions
|
@ -827,8 +827,8 @@ impl AlignedBlock {
|
||||||
self.render.lock()(cx)
|
self.render.lock()(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn disposition(&self) -> BlockDisposition {
|
pub fn position(&self) -> &Anchor {
|
||||||
self.block.disposition
|
&self.block.position
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::display_map::{BlockContext, BlockDisposition};
|
use crate::display_map::{BlockContext, ToDisplayPoint};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
DisplayPoint, Editor, EditorMode, EditorSettings, EditorStyle, Input, Scroll, Select,
|
DisplayPoint, Editor, EditorMode, EditorSettings, EditorStyle, Input, Scroll, Select,
|
||||||
|
@ -19,7 +19,7 @@ use gpui::{
|
||||||
MutableAppContext, PaintContext, Quad, Scene, SizeConstraint, ViewContext, WeakViewHandle,
|
MutableAppContext, PaintContext, Quad, Scene, SizeConstraint, ViewContext, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use json::json;
|
use json::json;
|
||||||
use language::Chunk;
|
use language::{Chunk, ToPoint};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use std::{
|
use std::{
|
||||||
cmp::{self, Ordering},
|
cmp::{self, Ordering},
|
||||||
|
@ -633,10 +633,11 @@ impl EditorElement {
|
||||||
snapshot
|
snapshot
|
||||||
.blocks_in_range(rows.clone())
|
.blocks_in_range(rows.clone())
|
||||||
.map(|(start_row, block)| {
|
.map(|(start_row, block)| {
|
||||||
let anchor_row = match block.disposition() {
|
let anchor_row = block
|
||||||
BlockDisposition::Above => start_row + block.height(),
|
.position()
|
||||||
BlockDisposition::Below => start_row - 1,
|
.to_point(&snapshot.buffer_snapshot)
|
||||||
};
|
.to_display_point(snapshot)
|
||||||
|
.row();
|
||||||
|
|
||||||
let anchor_x = if rows.contains(&anchor_row) {
|
let anchor_x = if rows.contains(&anchor_row) {
|
||||||
line_layouts[(anchor_row - rows.start) as usize]
|
line_layouts[(anchor_row - rows.start) as usize]
|
||||||
|
|
Loading…
Reference in a new issue