summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/editor/src/main.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/examples/editor/src/main.rs b/examples/editor/src/main.rs
index 7032324a..c039672e 100644
--- a/examples/editor/src/main.rs
+++ b/examples/editor/src/main.rs
@@ -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,
)
}