|
10 | 10 | using FlashDevelop.Utilities;
|
11 | 11 | using FlashDevelop.Helpers;
|
12 | 12 | using PluginCore.Managers;
|
| 13 | +using PluginCore.Utilities; |
13 | 14 | using PluginCore.Controls;
|
14 | 15 | using PluginCore.Helpers;
|
15 | 16 | using PluginCore;
|
@@ -39,9 +40,11 @@ public class SnippetDialog : SmartForm
|
39 | 40 | private System.Windows.Forms.Button addButton;
|
40 | 41 | private System.String currentSyntax;
|
41 | 42 | private System.Int32 folderCount;
|
| 43 | + private System.Int32 eolMode; |
42 | 44 |
|
43 | 45 | public SnippetDialog()
|
44 | 46 | {
|
| 47 | + this.eolMode = 0; |
45 | 48 | this.Owner = Globals.MainForm;
|
46 | 49 | this.Font = Globals.Settings.DefaultFont;
|
47 | 50 | this.FormGuid = "38535b88-d4b2-4db5-a6f5-40cc0ce3cb01";
|
@@ -435,6 +438,9 @@ private void SnippetListViewSelectedIndexChanged(Object sender, EventArgs e)
|
435 | 438 | String path = Path.Combine(this.SnippetDir, this.currentSyntax);
|
436 | 439 | path = Path.Combine(path, name + ".fds");
|
437 | 440 | String content = File.ReadAllText(path);
|
| 441 | + // Convert eols to windows and save current eol mode |
| 442 | + this.eolMode = LineEndDetector.DetectNewLineMarker(content, 0); |
| 443 | + content = content.Replace(LineEndDetector.GetNewLineMarker(this.eolMode), "\r\n"); |
438 | 444 | this.snippetNameTextBox.Text = name;
|
439 | 445 | this.contentsTextBox.Text = content;
|
440 | 446 | this.saveButton.Enabled = false;
|
@@ -639,6 +645,8 @@ private void ExportButtonClick(Object sender, EventArgs e)
|
639 | 645 | private void WriteFile(String name, String content)
|
640 | 646 | {
|
641 | 647 | StreamWriter file;
|
| 648 | + // Restore previous eol mode |
| 649 | + content = content.Replace("\r\n", LineEndDetector.GetNewLineMarker(this.eolMode)); |
642 | 650 | String path = Path.Combine(this.SnippetDir, this.currentSyntax);
|
643 | 651 | path = Path.Combine(path, name + ".fds");
|
644 | 652 | file = File.CreateText(path);
|
|
0 commit comments