From c62c13a38119b6b8b8fac4409cfe8b9da131d930 Mon Sep 17 00:00:00 2001 From: shichenshuo-star <280684216+shichenshuo-star@users.noreply.github.com> Date: Thu, 13 Aug 2026 14:06:04 +0800 Subject: [PATCH] fix: read body from stdin when --tags or template is set The stdin guard used note_content.is_empty(), but --tags or a template populate note_content with frontmatter before the body is read, so stdin was silently skipped and the note body was dropped. Now stdin is read whenever -c/--content is not provided and stdin is not a TTY, appending the body after any existing frontmatter. --- src/plugins/files.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/files.rs b/src/plugins/files.rs index 64dfab1..5a35e90 100644 --- a/src/plugins/files.rs +++ b/src/plugins/files.rs @@ -142,12 +142,14 @@ fn cmd_create( // Append content if let Some(ref c) = content { note_content.push_str(c); - } else if note_content.is_empty() { + } else if !is_terminal::is_terminal(io::stdin()) { + // Read the body from stdin when -c/--content is not provided, even if + // tags or a template already populated note_content (frontmatter). + // The previous guard (note_content.is_empty()) skipped stdin whenever + // --tags or a template had written frontmatter, silently dropping body. let mut buffer = String::new(); - if !is_terminal::is_terminal(io::stdin()) { - io::stdin().read_to_string(&mut buffer)?; - note_content = buffer; - } + io::stdin().read_to_string(&mut buffer)?; + note_content.push_str(&buffer); } if !note_content.ends_with('\n') {