Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added CWD option for editor.statusline #9291

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions helix-term/src/ui/statusline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ where
helix_view::editor::StatusLineElement::Spacer => render_spacer,
helix_view::editor::StatusLineElement::VersionControl => render_version_control,
helix_view::editor::StatusLineElement::Register => render_register,
helix_view::editor::StatusLineElement::WorkingDirectory => render_cwd,
}
}

Expand Down Expand Up @@ -514,3 +515,23 @@ where
write(context, format!(" reg={} ", reg), None)
}
}

fn render_cwd<F>(context: &mut RenderContext, write: F)
where
F: Fn(&mut RenderContext, String, Option<Style>) + Copy,
{
let cwd = std::env::current_dir();
let title: String = match cwd {
// Errors converting resolve to String::Default
Ok(path) => path
.iter()
.last()
.unwrap_or_default()
.to_owned()
.into_string()
.unwrap_or_default(),
Err(_) => "".into(),
};

write(context, title, None);
}
3 changes: 3 additions & 0 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,9 @@ pub enum StatusLineElement {

/// Indicator for selected register
Register,

/// Current Working Directory
WorkingDirectory,
}

// Cursor shape is read and used on every rendered frame and so needs
Expand Down