notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

commit 127897b23a15532973e680d9e9e45f9f28bf7948
parent d747fccd100af21e227d03bb4b7f228f368a907e
Author: William Casarin <jb55@jb55.com>
Date:   Mon,  9 Feb 2026 12:38:44 -0800

dave: extract abbreviate_path into shared path_utils module

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Diffstat:
Mcrates/notedeck_dave/src/ui/directory_picker.rs | 13++-----------
Mcrates/notedeck_dave/src/ui/mod.rs | 1+
Acrates/notedeck_dave/src/ui/path_utils.rs | 11+++++++++++
Mcrates/notedeck_dave/src/ui/session_picker.rs | 11+----------
4 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/crates/notedeck_dave/src/ui/directory_picker.rs b/crates/notedeck_dave/src/ui/directory_picker.rs @@ -1,6 +1,7 @@ use crate::ui::keybind_hint::paint_keybind_hint; +use crate::ui::path_utils::abbreviate_path; use egui::{RichText, Vec2}; -use std::path::{Path, PathBuf}; +use std::path::PathBuf; /// Maximum number of recent directories to store const MAX_RECENT_DIRECTORIES: usize = 10; @@ -342,13 +343,3 @@ impl DirectoryPicker { action } } - -/// Abbreviate a path for display (e.g., replace home dir with ~) -fn abbreviate_path(path: &Path) -> String { - if let Some(home) = dirs::home_dir() { - if let Ok(relative) = path.strip_prefix(&home) { - return format!("~/{}", relative.display()); - } - } - path.display().to_string() -} diff --git a/crates/notedeck_dave/src/ui/mod.rs b/crates/notedeck_dave/src/ui/mod.rs @@ -5,6 +5,7 @@ pub mod diff; pub mod directory_picker; pub mod keybind_hint; pub mod keybindings; +pub mod path_utils; mod pill; mod query_ui; pub mod scene; diff --git a/crates/notedeck_dave/src/ui/path_utils.rs b/crates/notedeck_dave/src/ui/path_utils.rs @@ -0,0 +1,11 @@ +use std::path::Path; + +/// Abbreviate a path for display (e.g., replace home dir with ~) +pub fn abbreviate_path(path: &Path) -> String { + if let Some(home) = dirs::home_dir() { + if let Ok(relative) = path.strip_prefix(&home) { + return format!("~/{}", relative.display()); + } + } + path.display().to_string() +} diff --git a/crates/notedeck_dave/src/ui/session_picker.rs b/crates/notedeck_dave/src/ui/session_picker.rs @@ -2,6 +2,7 @@ use crate::session_discovery::{discover_sessions, format_relative_time, ResumableSession}; use crate::ui::keybind_hint::paint_keybind_hint; +use crate::ui::path_utils::abbreviate_path; use egui::{RichText, Vec2}; use std::path::{Path, PathBuf}; @@ -308,13 +309,3 @@ impl SessionPicker { action } } - -/// Abbreviate a path for display (e.g., replace home dir with ~) -fn abbreviate_path(path: &Path) -> String { - if let Some(home) = dirs::home_dir() { - if let Ok(relative) = path.strip_prefix(&home) { - return format!("~/{}", relative.display()); - } - } - path.display().to_string() -}