From 7738e9d6520d1972ae430707ad1b517ac044237a Mon Sep 17 00:00:00 2001 From: Saheed Adeleye Date: Tue, 27 May 2025 23:24:28 +0100 Subject: [PATCH 1/3] use human-readable sizes for file size on save/write --- helix-term/src/application.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 6f3485a87..9546af942 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -571,16 +571,24 @@ impl Application { doc.set_last_saved_revision(doc_save_event.revision, doc_save_event.save_time); let lines = doc_save_event.text.len_lines(); - let bytes = doc_save_event.text.len_bytes(); + let mut sz = doc_save_event.text.len_bytes() as f32; + + const SUFFIX: [&str; 7] = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"]; + let mut i = 0; + while i < SUFFIX.len() - 1 && sz >= 1024.0 { + sz /= 1024.0; + i += 1; + } self.editor .set_doc_path(doc_save_event.doc_id, &doc_save_event.path); // TODO: fix being overwritten by lsp self.editor.set_status(format!( - "'{}' written, {}L {}B", + "'{}' written, {}L {:.1}{}", get_relative_path(&doc_save_event.path).to_string_lossy(), lines, - bytes + sz, + SUFFIX[i], )); } From d2f6b26dddcb5ed7998e5a5f2d9dcc75157416da Mon Sep 17 00:00:00 2001 From: Saheed Adeleye Date: Wed, 28 May 2025 02:05:34 +0100 Subject: [PATCH 2/3] use human-readable sizes pls --- helix-term/src/application.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 9546af942..91713f6a1 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -573,7 +573,7 @@ impl Application { let lines = doc_save_event.text.len_lines(); let mut sz = doc_save_event.text.len_bytes() as f32; - const SUFFIX: [&str; 7] = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"]; + const SUFFIX: [&str; 4] = ["B", "KB", "MB", "GB"]; let mut i = 0; while i < SUFFIX.len() - 1 && sz >= 1024.0 { sz /= 1024.0; From 46101ace886ada8fa011dcdf061c746ab643251f Mon Sep 17 00:00:00 2001 From: Saheed Adeleye Date: Mon, 9 Jun 2025 09:27:04 +0100 Subject: [PATCH 3/3] use IEC units, again --- helix-term/src/application.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index c8231bad3..2b2ff8551 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -571,7 +571,7 @@ impl Application { let lines = doc_save_event.text.len_lines(); let mut sz = doc_save_event.text.len_bytes() as f32; - const SUFFIX: [&str; 4] = ["B", "KB", "MB", "GB"]; + const SUFFIX: [&str; 4] = ["B", "KiB", "MiB", "GiB"]; let mut i = 0; while i < SUFFIX.len() - 1 && sz >= 1024.0 { sz /= 1024.0;