From 4d9c647edb57f4faa864326a690968d2dbb08668 Mon Sep 17 00:00:00 2001 From: bluepilledgreat <97983689+bluepilledgreat@users.noreply.github.com> Date: Thu, 24 Oct 2024 18:06:57 +0100 Subject: [PATCH] make sure file contents are in CRLF --- .../Elements/Editor/BootstrapperEditorWindow.xaml.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Bloxstrap/UI/Elements/Editor/BootstrapperEditorWindow.xaml.cs b/Bloxstrap/UI/Elements/Editor/BootstrapperEditorWindow.xaml.cs index a35dc8f..63acc34 100644 --- a/Bloxstrap/UI/Elements/Editor/BootstrapperEditorWindow.xaml.cs +++ b/Bloxstrap/UI/Elements/Editor/BootstrapperEditorWindow.xaml.cs @@ -133,10 +133,13 @@ namespace Bloxstrap.UI.Elements.Editor { CustomBootstrapperSchema.ParseSchema(); + string themeContents = File.ReadAllText(Path.Combine(Paths.CustomThemes, name, "Theme.xml")); + themeContents = ToCRLF(themeContents); // make sure the theme is in CRLF. a function expects CRLF. + var viewModel = new BootstrapperEditorWindowViewModel(); viewModel.Name = name; viewModel.Title = $"Editing \"{name}\""; - viewModel.Code = File.ReadAllText(Path.Combine(Paths.CustomThemes, name, "Theme.xml")); + viewModel.Code = themeContents; DataContext = viewModel; InitializeComponent(); @@ -145,6 +148,11 @@ namespace Bloxstrap.UI.Elements.Editor UIXML.TextArea.TextEntered += OnTextAreaTextEntered; } + private static string ToCRLF(string text) + { + return text.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n"); + } + private void OnCodeChanged(object sender, EventArgs e) { BootstrapperEditorWindowViewModel viewModel = (BootstrapperEditorWindowViewModel)DataContext;