Improve DisplayPoint Debug impl

This commit is contained in:
Nathan Sobo 2022-03-21 21:07:56 -06:00
parent e5a00d72f8
commit f70f4c7729

View file

@ -12,7 +12,7 @@ use gpui::{
Entity, ModelContext, ModelHandle,
};
use language::{Point, Subscription as BufferSubscription};
use std::{any::TypeId, ops::Range, sync::Arc};
use std::{any::TypeId, fmt::Debug, ops::Range, sync::Arc};
use sum_tree::{Bias, TreeMap};
use tab_map::TabMap;
use wrap_map::WrapMap;
@ -414,9 +414,19 @@ impl DisplaySnapshot {
}
}
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
#[derive(Copy, Clone, Default, Eq, Ord, PartialOrd, PartialEq)]
pub struct DisplayPoint(BlockPoint);
impl Debug for DisplayPoint {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_fmt(format_args!(
"DisplayPoint({}, {})",
self.row(),
self.column()
))
}
}
impl DisplayPoint {
pub fn new(row: u32, column: u32) -> Self {
Self(BlockPoint(Point::new(row, column)))
@ -426,7 +436,6 @@ impl DisplayPoint {
Self::new(0, 0)
}
#[cfg(test)]
pub fn is_zero(&self) -> bool {
self.0.is_zero()
}