helix-term/editor: display scratch buffer name in status bar

pull/999/head
Cole Helbling 3 years ago committed by Gokul Soumya
parent b824e091a9
commit b74912ea78

@ -16,7 +16,7 @@ use helix_core::{
LineEnding, Position, Range, Selection, LineEnding, Position, Range, Selection,
}; };
use helix_view::{ use helix_view::{
document::Mode, document::{Mode, SCRATCH_BUFFER_NAME},
editor::LineNumber, editor::LineNumber,
graphics::{CursorKind, Modifier, Rect, Style}, graphics::{CursorKind, Modifier, Rect, Style},
info::Info, info::Info,
@ -580,18 +580,20 @@ impl EditorView {
} }
surface.set_string(viewport.x + 5, viewport.y, progress, base_style); surface.set_string(viewport.x + 5, viewport.y, progress, base_style);
if let Some(path) = doc.relative_path() { let rel_path = doc.relative_path();
let path = path.to_string_lossy(); 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 { "" }); let title = format!("{}{}", path, if doc.is_modified() { "[+]" } else { "" });
surface.set_stringn( surface.set_stringn(
viewport.x + 8, viewport.x + 8,
viewport.y, viewport.y,
title, title,
viewport.width.saturating_sub(6) as usize, viewport.width.saturating_sub(6) as usize,
base_style, base_style,
); );
}
//------------------------------- //-------------------------------
// Right side of the status line. // Right side of the status line.

Loading…
Cancel
Save