mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 13:24:19 +00:00
💄 Add Buffer::row_count
This commit is contained in:
parent
7c084846af
commit
3c0673852b
2 changed files with 6 additions and 6 deletions
|
@ -692,7 +692,6 @@ impl Buffer {
|
|||
|
||||
fn autoindent_for_rows(&self, rows: Range<u32>) -> Vec<usize> {
|
||||
let mut indents = Vec::new();
|
||||
let mut indent = 2;
|
||||
if let Some((language, syntax_tree)) = self.language.as_ref().zip(self.syntax_tree()) {
|
||||
let mut stack = Vec::new();
|
||||
let mut cursor = syntax_tree.walk();
|
||||
|
@ -855,6 +854,10 @@ impl Buffer {
|
|||
self.visible_text.max_point()
|
||||
}
|
||||
|
||||
pub fn row_count(&self) -> u32 {
|
||||
self.max_point().row + 1
|
||||
}
|
||||
|
||||
pub fn text(&self) -> String {
|
||||
self.text_for_range(0..self.len()).collect()
|
||||
}
|
||||
|
@ -3757,7 +3760,7 @@ mod tests {
|
|||
buffer.condition(&ctx, |buf, _| !buf.is_parsing()).await;
|
||||
buffer.read_with(&ctx, |buf, _| {
|
||||
assert_eq!(
|
||||
buf.autoindent_for_rows(0..buf.max_point().row + 1),
|
||||
buf.autoindent_for_rows(0..buf.row_count()),
|
||||
vec![0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 0, 0, 0, 0, 0]
|
||||
);
|
||||
todo!("write assertions to test how indents work with different subset of rows");
|
||||
|
|
|
@ -2074,10 +2074,7 @@ impl BufferView {
|
|||
let font_size = settings.buffer_font_size;
|
||||
let font_id =
|
||||
font_cache.select_font(settings.buffer_font_family, &FontProperties::new())?;
|
||||
let digit_count = ((self.buffer.read(app).max_point().row + 1) as f32)
|
||||
.log10()
|
||||
.floor() as usize
|
||||
+ 1;
|
||||
let digit_count = (self.buffer.read(app).row_count() as f32).log10().floor() as usize + 1;
|
||||
|
||||
Ok(layout_cache
|
||||
.layout_str(
|
||||
|
|
Loading…
Reference in a new issue