Browse Source

When saving code snippets, remove any completely empty snippets (might have been added accidentally by clicking into the grid's empty row).

pull/1/head
Daniel Grunwald 16 years ago
parent
commit
63a5936468
  1. 13
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/SnippetOptionPanel.cs

13
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Snippets/SnippetOptionPanel.cs

@ -49,6 +49,13 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets
public bool SaveOptions() public bool SaveOptions()
{ {
CodeSnippet emptySnippet = new CodeSnippet();
foreach (CodeSnippetGroup g in groups) {
for (int i = 0; i < g.Snippets.Count; i++) {
if (emptySnippet.Equals(g.Snippets[i]))
g.Snippets.RemoveAt(i--);
}
}
SnippetManager.Instance.SaveGroups(groups); SnippetManager.Instance.SaveGroups(groups);
return true; return true;
} }
@ -56,9 +63,9 @@ namespace ICSharpCode.AvalonEdit.AddIn.Snippets
void AddGroupButton_Click(object sender, RoutedEventArgs e) void AddGroupButton_Click(object sender, RoutedEventArgs e)
{ {
string result = MessageService.ShowInputBox( string result = MessageService.ShowInputBox(
"${res:Dialog.Options.CodeTemplate.AddGroupLabel}", "${res:Dialog.Options.CodeTemplate.AddGroupLabel}",
"${res:Dialog.Options.CodeTemplate.EditGroupDialog.Text}", "${res:Dialog.Options.CodeTemplate.EditGroupDialog.Text}",
""); "");
if (!string.IsNullOrEmpty(result)) { if (!string.IsNullOrEmpty(result)) {
CodeSnippetGroup g = new CodeSnippetGroup(); CodeSnippetGroup g = new CodeSnippetGroup();
g.Extensions = result; g.Extensions = result;

Loading…
Cancel
Save