summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor <hector@hecrj.dev>2025-01-28 06:36:19 +0100
committerLibravatar GitHub <noreply@github.com>2025-01-28 06:36:19 +0100
commitce4ee9323d31d7f346b1d775945f7629f3c5ab64 (patch)
treed057c83712b9228b787adb8ac327b25bbf95795c /examples
parent00a048677fc43a5e3106dff17e0c1c490fdc5ce1 (diff)
parent87165ccd29f0e85a26774ec090d8400274c6d04e (diff)
downloadiced-ce4ee9323d31d7f346b1d775945f7629f3c5ab64.tar.gz
iced-ce4ee9323d31d7f346b1d775945f7629f3c5ab64.tar.bz2
iced-ce4ee9323d31d7f346b1d775945f7629f3c5ab64.zip
Merge pull request #2759 from iced-rs/fix/respect-editor-line-endings
Introduce `LineEnding` to `editor` and fix inconsistencies
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,
)
}