on master help sign in
Truncate the start of file paths in the StatusLine (#1351)
60f3225BB
helix-term/src/ui/editor.rs+25−15
@@ -548,21 +548,6 @@ impl EditorView {
548 }
548 }
549 surface.set_string(viewport.x + 5, viewport.y, progress, base_style);
549 surface.set_string(viewport.x + 5, viewport.y, progress, base_style);
550
550
551− let rel_path = doc.relative_path();
552− let path = rel_path
553− .as_ref()
554− .map(|p| p.to_string_lossy())
555− .unwrap_or_else(|| SCRATCH_BUFFER_NAME.into());
556−
557− let title = format!("{}{}", path, if doc.is_modified() { "[+]" } else { "" });
558− surface.set_stringn(
559− viewport.x + 8,
560− viewport.y,
561− title,
562− viewport.width.saturating_sub(6) as usize,
563− base_style,
564− );
565−
566 //-------------------------------
551 //-------------------------------
567 // Right side of the status line.
552 // Right side of the status line.
568 //-------------------------------
553 //-------------------------------
@@ -646,6 +631,31 @@ impl EditorView {
646 &right_side_text,
631 &right_side_text,
647 right_side_text.width() as u16,
632 right_side_text.width() as u16,
648 );
633 );
634+
635+ //-------------------------------
636+ // Middle / File path / Title
637+ //-------------------------------
638+ let title = {
639+ let rel_path = doc.relative_path();
640+ let path = rel_path
641+ .as_ref()
642+ .map(|p| p.to_string_lossy())
643+ .unwrap_or_else(|| SCRATCH_BUFFER_NAME.into());
644+ format!("{}{}", path, if doc.is_modified() { "[+]" } else { "" })
645+ };
646+
647+ surface.set_string_truncated(
648+ viewport.x + 8, // 8: 1 space + 3 char mode string + 1 space + 1 spinner + 1 space
649+ viewport.y,
650+ title,
651+ viewport
652+ .width
653+ .saturating_sub(6)
654+ .saturating_sub(right_side_text.width() as u16 + 1) as usize, // "+ 1": a space between the title and the selection info
655+ base_style,
656+ true,
657+ true,
658+ );
649 }
659 }
650
660
651 /// Handle events by looking them up in `self.keymaps`. Returns None
661 /// Handle events by looking them up in `self.keymaps`. Returns None