mirror of https://github.com/helix-editor/helix
add parent directory to bufferline
parent
340934db92
commit
a4974f3d5a
|
@ -633,9 +633,8 @@ impl EditorView {
|
|||
let current_doc = view!(editor).doc;
|
||||
|
||||
for doc in editor.documents() {
|
||||
let fname = doc
|
||||
.path()
|
||||
.unwrap_or(&scratch)
|
||||
let path = doc.path().unwrap_or(&scratch);
|
||||
let fname = path
|
||||
.file_name()
|
||||
.unwrap_or_default()
|
||||
.to_str()
|
||||
|
@ -647,7 +646,20 @@ impl EditorView {
|
|||
bufferline_inactive
|
||||
};
|
||||
|
||||
let text = format!(" {}{} ", fname, if doc.is_modified() { "[+]" } else { "" });
|
||||
let text = if editor.config().bufferline_show_parent {
|
||||
let parent_dir = path
|
||||
.parent()
|
||||
.and_then(|p| p.file_name().unwrap_or_default().to_str())
|
||||
.unwrap_or_default();
|
||||
format!(
|
||||
" {}/{}{} ",
|
||||
parent_dir,
|
||||
fname,
|
||||
if doc.is_modified() { "[+]" } else { "" }
|
||||
)
|
||||
} else {
|
||||
format!(" {}{} ", fname, if doc.is_modified() { "[+]" } else { "" })
|
||||
};
|
||||
let used_width = viewport.x.saturating_sub(x);
|
||||
let rem_width = surface.area.width.saturating_sub(used_width);
|
||||
|
||||
|
|
|
@ -332,6 +332,8 @@ pub struct Config {
|
|||
pub whitespace: WhitespaceConfig,
|
||||
/// Persistently display open buffers along the top
|
||||
pub bufferline: BufferLine,
|
||||
/// Show the parent directory of files in the bufferline.
|
||||
pub bufferline_show_parent: bool,
|
||||
/// Vertical indent width guides.
|
||||
pub indent_guides: IndentGuidesConfig,
|
||||
/// Whether to color modes with different colors. Defaults to `false`.
|
||||
|
@ -999,6 +1001,7 @@ impl Default for Config {
|
|||
rulers: Vec::new(),
|
||||
whitespace: WhitespaceConfig::default(),
|
||||
bufferline: BufferLine::default(),
|
||||
bufferline_show_parent: false,
|
||||
indent_guides: IndentGuidesConfig::default(),
|
||||
color_modes: false,
|
||||
soft_wrap: SoftWrap {
|
||||
|
|
Loading…
Reference in New Issue