Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/commands/typed.rs')
-rw-r--r--helix-term/src/commands/typed.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index 27e2c75d..ffe58adf 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -185,9 +185,7 @@ fn buffer_gather_paths_impl(editor: &mut Editor, args: Args) -> Vec<DocumentId>
for arg in args {
let doc_id = editor.documents().find_map(|doc| {
let arg_path = Some(Path::new(arg));
- if doc.path().map(|p| p.as_path()) == arg_path
- || doc.relative_path().as_deref() == arg_path
- {
+ if doc.path().map(|p| p.as_path()) == arg_path || doc.relative_path() == arg_path {
Some(doc.id())
} else {
None
@@ -625,11 +623,12 @@ fn force_write_quit(
/// error, otherwise returns `Ok(())`. If the current document is unmodified,
/// and there are modified documents, switches focus to one of them.
pub(super) fn buffers_remaining_impl(editor: &mut Editor) -> anyhow::Result<()> {
- let (modified_ids, modified_names): (Vec<_>, Vec<_>) = editor
+ let modified_ids: Vec<_> = editor
.documents()
.filter(|doc| doc.is_modified())
- .map(|doc| (doc.id(), doc.display_name()))
- .unzip();
+ .map(|doc| doc.id())
+ .collect();
+
if let Some(first) = modified_ids.first() {
let current = doc!(editor);
// If the current document is unmodified, and there are modified
@@ -637,6 +636,12 @@ pub(super) fn buffers_remaining_impl(editor: &mut Editor) -> anyhow::Result<()>
if !modified_ids.contains(&current.id()) {
editor.switch(*first, Action::Replace);
}
+
+ let modified_names: Vec<_> = modified_ids
+ .iter()
+ .map(|doc_id| doc!(editor, doc_id).display_name())
+ .collect();
+
bail!(
"{} unsaved buffer{} remaining: {:?}",
modified_names.len(),
@@ -1023,14 +1028,14 @@ fn change_current_directory(
let dir = match args.next() {
Some("-") => cx
.editor
- .last_cwd
- .clone()
+ .get_last_cwd()
+ .map(|path| Cow::Owned(path.to_path_buf()))
.ok_or_else(|| anyhow!("No previous working directory"))?,
- Some(path) => helix_stdx::path::expand_tilde(Path::new(path)).to_path_buf(),
- None => home_dir()?,
+ Some(path) => helix_stdx::path::expand_tilde(Path::new(path)),
+ None => Cow::Owned(home_dir()?),
};
- cx.editor.last_cwd = helix_stdx::env::set_current_working_dir(dir)?;
+ cx.editor.set_cwd(&dir)?;
cx.editor.set_status(format!(
"Current working directory is now {}",