From f70f4c77293b8cec39ad80b22d97310301244200 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 21 Mar 2022 21:07:56 -0600 Subject: [PATCH] Improve DisplayPoint Debug impl --- crates/editor/src/display_map.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/editor/src/display_map.rs b/crates/editor/src/display_map.rs index dbadbb386e..17209e5c74 100644 --- a/crates/editor/src/display_map.rs +++ b/crates/editor/src/display_map.rs @@ -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() }