Introduce LineEnding to editor and fix inconsistencies

This commit is contained in:
Héctor Ramón Jiménez 2025-01-28 06:23:38 +01:00
parent 00a048677f
commit 87165ccd29
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
5 changed files with 93 additions and 60 deletions

View file

@ -117,8 +117,16 @@ impl Editor {
} else {
self.is_loading = true;
let mut text = self.content.text();
if let Some(ending) = self.content.line_ending() {
if !text.ends_with(ending.as_str()) {
text.push_str(ending.as_str());
}
}
Task::perform(
save_file(self.file.clone(), self.content.text()),
save_file(self.file.clone(), text),
Message::FileSaved,
)
}