Skip to content

Commit 7442ce6

Browse files
authored
Trim trailing whitespace in content comparison to reduce DB updates (#92)
1 parent 7bbafc5 commit 7442ce6

File tree

1 file changed

+4
-2
lines changed
  • core/src/state/notebook/consume

1 file changed

+4
-2
lines changed

core/src/state/notebook/consume/note.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,10 @@ pub async fn update_content(
127127
content: String,
128128
) -> Result<NotebookTransition> {
129129
let current = db.fetch_note_content(note_id.clone()).await?;
130-
if current != content {
131-
db.update_note_content(note_id.clone(), content).await?;
130+
let content = content.trim_end();
131+
if current.trim_end() != content {
132+
db.update_note_content(note_id.clone(), content.to_owned())
133+
.await?;
132134
}
133135

134136
Ok(NotebookTransition::UpdateNoteContent(note_id))

0 commit comments

Comments
 (0)