on master help sign in
helix-term/editor: display scratch buffer name in status bar
commitb74912ea78079cde3e1ee3b2dc1a2a6d68568a36 authorCole Helbling <cole.e.helbling@outlook.com> dateSat 13 Nov 2021, 12:44 (5 years ago) parentb824e09
1 file changed+14−12
helix-term/src/ui/editor.rs+14−12
helix-term/src/ui/editor.rs+14−12
@@ -16,7 +16,7 @@ use helix_core::{
1616 LineEnding, Position, Range, Selection,
1717};
1818use helix_view::{
19− document::Mode,
19+ document::{Mode, SCRATCH_BUFFER_NAME},
2020 editor::LineNumber,
2121 graphics::{CursorKind, Modifier, Rect, Style},
2222 info::Info,
@@ -580,18 +580,20 @@ impl EditorView {
580580 }
581581 surface.set_string(viewport.x + 5, viewport.y, progress, base_style);
582582
583− if let Some(path) = doc.relative_path() {
584− let path = path.to_string_lossy();
583+ let rel_path = doc.relative_path();
584+ let path = rel_path
585+ .as_ref()
586+ .map(|p| p.to_string_lossy())
587+ .unwrap_or_else(|| SCRATCH_BUFFER_NAME.into());
585588
586− let title = format!("{}{}", path, if doc.is_modified() { "[+]" } else { "" });
587− surface.set_stringn(
588− viewport.x + 8,
589− viewport.y,
590− title,
591− viewport.width.saturating_sub(6) as usize,
592− base_style,
593− );
594− }
589+ let title = format!("{}{}", path, if doc.is_modified() { "[+]" } else { "" });
590+ surface.set_stringn(
591+ viewport.x + 8,
592+ viewport.y,
593+ title,
594+ viewport.width.saturating_sub(6) as usize,
595+ base_style,
596+ );
595597
596598 //-------------------------------
597599 // Right side of the status line.