aboutsummaryrefslogtreecommitdiff
path: root/helix-term
diff options
context:
space:
mode:
authorCole Helbling2021-11-13 20:44:51 +0000
committerGokul Soumya2021-11-14 07:03:17 +0000
commitb74912ea78079cde3e1ee3b2dc1a2a6d68568a36 (patch)
tree2bb40fe27037f4d14480d904ce7ac81a5bffc028 /helix-term
parentb824e091a948c076a428fb981cd5be2929378533 (diff)
helix-term/editor: display scratch buffer name in status bar
Diffstat (limited to 'helix-term')
-rw-r--r--helix-term/src/ui/editor.rs26
1 files changed, 14 insertions, 12 deletions
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 90f09e9c..dcf87203 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -16,7 +16,7 @@ use helix_core::{
LineEnding, Position, Range, Selection,
};
use helix_view::{
- document::Mode,
+ document::{Mode, SCRATCH_BUFFER_NAME},
editor::LineNumber,
graphics::{CursorKind, Modifier, Rect, Style},
info::Info,
@@ -580,18 +580,20 @@ impl EditorView {
}
surface.set_string(viewport.x + 5, viewport.y, progress, base_style);
- if let Some(path) = doc.relative_path() {
- let path = path.to_string_lossy();
+ let rel_path = doc.relative_path();
+ let path = rel_path
+ .as_ref()
+ .map(|p| p.to_string_lossy())
+ .unwrap_or_else(|| SCRATCH_BUFFER_NAME.into());
- let title = format!("{}{}", path, if doc.is_modified() { "[+]" } else { "" });
- surface.set_stringn(
- viewport.x + 8,
- viewport.y,
- title,
- viewport.width.saturating_sub(6) as usize,
- base_style,
- );
- }
+ let title = format!("{}{}", path, if doc.is_modified() { "[+]" } else { "" });
+ surface.set_stringn(
+ viewport.x + 8,
+ viewport.y,
+ title,
+ viewport.width.saturating_sub(6) as usize,
+ base_style,
+ );
//-------------------------------
// Right side of the status line.