aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands
diff options
context:
space:
mode:
authorSkyler Hawthorne2022-04-24 19:33:43 +0000
committerSkyler Hawthorne2022-10-19 02:31:38 +0000
commit83b6042b97d13fca751e3d5d0c32f04e3ad04c9a (patch)
tree42fb0367fcd09868371687e3ccbe27abf2de4762 /helix-term/src/commands
parenta5a93182cd5ccf88bc95b68044aa05d746ded35e (diff)
fix(write): do not set new path on document until write succeeds
If a document is written with a new path, currently, in the event that the write fails, the document still gets its path changed. This fixes it so that the path is not updated unless the write succeeds.
Diffstat (limited to 'helix-term/src/commands')
-rw-r--r--helix-term/src/commands/typed.rs9
1 files changed, 2 insertions, 7 deletions
diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs
index 375e7b4f..35c84601 100644
--- a/helix-term/src/commands/typed.rs
+++ b/helix-term/src/commands/typed.rs
@@ -268,11 +268,6 @@ fn write_impl(
let jobs = &mut cx.jobs;
let doc = doc_mut!(cx.editor);
- if let Some(ref path) = path {
- doc.set_path(Some(path.as_ref().as_ref()))
- .context("invalid filepath")?;
- }
-
if doc.path().is_none() {
bail!("cannot write a buffer without a filename");
}
@@ -292,7 +287,7 @@ fn write_impl(
None
};
- doc.format_and_save(fmt, force)?;
+ doc.format_and_save(fmt, path.map(AsRef::as_ref), force)?;
if path.is_some() {
let id = doc.id();
@@ -607,7 +602,7 @@ fn write_all_impl(
None
};
- doc.format_and_save(fmt, force)?;
+ doc.format_and_save::<_, PathBuf>(fmt, None, force)?;
}
if quit {