Fix pasting sections

This commit is contained in:
azakhi 2018-08-11 13:15:21 +03:00
parent f6969a0204
commit 216168533f
2 changed files with 25 additions and 3 deletions

View File

@ -543,7 +543,7 @@ namespace Filtration.Parser.Services
if (!string.IsNullOrEmpty(block.Description)) if (!string.IsNullOrEmpty(block.Description))
{ {
outputString += "# " + block.Description + Environment.NewLine; outputString += (block.Enabled ? "# " : "## ") + block.Description + Environment.NewLine;
} }
outputString += (!block.Enabled ? "#" : string.Empty) + block.Action.GetAttributeDescription(); outputString += (!block.Enabled ? "#" : string.Empty) + block.Action.GetAttributeDescription();

View File

@ -778,6 +778,16 @@ namespace Filtration.ViewModels
public void PasteBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase) public void PasteBlock(IItemFilterBlockViewModelBase targetBlockViewModelBase)
{ {
var commentBlock = targetBlockViewModelBase as IItemFilterCommentBlockViewModel;
if(commentBlock != null && !commentBlock.IsExpanded)
{
var blockIndex = ItemFilterBlockViewModels.IndexOf(targetBlockViewModelBase) + 1;
while (blockIndex < ItemFilterBlockViewModels.Count && (ItemFilterBlockViewModels[blockIndex] as IItemFilterCommentBlockViewModel) == null)
{
blockIndex++;
}
targetBlockViewModelBase = ItemFilterBlockViewModels[blockIndex - 1];
}
try try
{ {
var clipboardText = _clipboardService.GetClipboardText(); var clipboardText = _clipboardService.GetClipboardText();
@ -793,7 +803,20 @@ namespace Filtration.ViewModels
{ {
IItemFilterBlockBase translatedBlock; IItemFilterBlockBase translatedBlock;
var pastedDisabledBlock = false; var pastedDisabledBlock = false;
if (!curBlock.StartsWith(@"#Disabled Block Start") && curBlock.StartsWith(@"#")) var isCommentBlock = !curBlock.StartsWith(@"#Disabled Block Start");
string[] textLines = curBlock.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
foreach(var line in textLines)
{
if(!line.StartsWith(@"#"))
{
isCommentBlock = false;
}
if (!isCommentBlock)
break;
}
if (isCommentBlock)
{ {
translatedBlock = _blockTranslator.TranslateStringToItemFilterCommentBlock(curBlock, Script); translatedBlock = _blockTranslator.TranslateStringToItemFilterCommentBlock(curBlock, Script);
pastedSection = true; pastedSection = true;
@ -801,7 +824,6 @@ namespace Filtration.ViewModels
else if (curBlock.StartsWith(@"#Disabled Block Start")) else if (curBlock.StartsWith(@"#Disabled Block Start"))
{ {
pastedDisabledBlock = true; pastedDisabledBlock = true;
string[] textLines = curBlock.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
if (textLines.Length < 3) if (textLines.Length < 3)
continue; continue;