From: Olaf Wintermann Date: Fri, 29 May 2026 16:44:55 +0000 (+0200) Subject: fix note title updates using not the current note content X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;ds=sidebyside;p=note.git fix note title updates using not the current note content --- diff --git a/application/src/note.rs b/application/src/note.rs index c46c776..b49dbbc 100644 --- a/application/src/note.rs +++ b/application/src/note.rs @@ -130,20 +130,30 @@ impl Note { return; } + let mut content = "".to_string(); // check if any text in the title range has changed let pos = match &event.event_type { - EventType::TextInsert(t) => t.pos, - EventType::TextDelete(t) => t.begin, + EventType::TextInsert(t) => { + content = self.text.get(); + content.insert_str(t.pos as usize, t.text.as_str()); + t.pos + }, + EventType::TextDelete(t) => { + content = self.text.get(); + let range = t.begin as usize..t.end as usize; + content.replace_range(range, ""); + t.begin + }, _ => { return; } }; if self.title_end != -1 && pos > self.title_end + 1 { - return; // this text edit can not change the title + //return; // this text edit can not change the title } // TODO: we don't need the full text - self.update_title(self.text.get().as_str(), true); + self.update_title(content.as_str(), true); } } diff --git a/application/src/notebook.rs b/application/src/notebook.rs index ad83900..f3b9fd1 100644 --- a/application/src/notebook.rs +++ b/application/src/notebook.rs @@ -124,8 +124,8 @@ impl Notebook { if let Some(title) = &u.title { note.title = title.clone(); } + update_rows.push(i); } - update_rows.push(i); } } }