Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/plugins/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down