Skip to content

Commit 98c170d

Browse files
author
Sébastien Geiser
committed
Save documents when replace directories in editor
1 parent 0558c92 commit 98c170d

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

CSharpRegexTools4Npp/Main.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,11 @@ public static void ShowTheDialog()
135135
BNpp.AddSelection(index, index + length);
136136
},
137137

138-
GetSelectionStartIndex = delegate ()
139-
{
140-
return BNpp.SelectionStart;
141-
},
138+
GetSelectionStartIndex = () => BNpp.SelectionStart,
142139

143-
GetSelectionLength = delegate ()
144-
{
145-
return BNpp.SelectionLength;
146-
},
140+
GetSelectionLength = () => BNpp.SelectionLength,
141+
142+
SaveCurrentDocument = () => BNpp.SaveCurrentDocument(),
147143

148144
TryOpen = delegate (string fileName, bool onlyIfAlreadyOpen)
149145
{

RegexDialog/RegExToolDialog.xaml.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using System.Collections.ObjectModel;
1010
using System.IO;
1111
using System.Linq;
12-
using System.Reflection;
1312
using System.Text;
1413
using System.Text.RegularExpressions;
1514
using System.Windows;
@@ -91,6 +90,11 @@ public partial class RegExToolDialog : Window
9190
/// </summary>
9291
public TryOpenDelegate TryOpen { get; set; }
9392

93+
/// <summary>
94+
/// Save the document in the current tab
95+
/// </summary>
96+
public Action SaveCurrentDocument { get; set; }
97+
9498
/// <summary>
9599
/// Get the name of the current fileName in the editor
96100
/// </summary>
@@ -579,6 +583,12 @@ private void ReplaceAllButton_Click(object sender, RoutedEventArgs e)
579583
return script.Replace(match, index, fileName, nbrOfElementToReplace, files);
580584
}));
581585

586+
try
587+
{
588+
SaveCurrentDocument();
589+
}
590+
catch {}
591+
582592
files++;
583593
}
584594
}

0 commit comments

Comments
 (0)