-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove priority key and change delete tag execution logic #350
Remove priority key and change delete tag execution logic #350
Conversation
var errorsList = new TemplateErrors(); | ||
var tagList = new TagsList(errorsList); | ||
foreach (var cell in cells) | ||
{ | ||
tagList.Add(CreateInRangeTag<DeleteTag>(range, range.Cell(cell))); | ||
} | ||
|
||
tagList.Execute(new ProcessingContext(range, new DataSource(Array.Empty<object>()), new FormulaEvaluator())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I would recommend not to put "arrange" and "act" in one method - it is harder to grasp the idea of tests this way.
Extract tagList.Execute...
into a separate method (e.g. Act(IXLRange range)
) and rename the setup methods to womething like AddTagsToRange
, AddTagsToWorksheet
. Besides, by making cells
the last parameters, you can utilize params
keyword and make the invocation yet simpler:
AddTagsToRange(rng, "B2");
AddTagsToWorksheet("A3", "A4", "C1", "D1");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it would be amalizing if you can cover conditional delete with a test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solution will not fix deleting rows after or inside named range, it requires additional recalculation of the tag cell address. We will try to provide a solution for these cases, but for now the column deletion needs to be fixed
Awesome job! Thanks for the contribution and keep going ;) |
We are encountering an issue where columns are not being removed correctly using the Delete tag. This occurs because the deletion order depended on the PriorityKey calculation. The higher the PriorityKey, the sooner the column will be deleted. The current PriorityKey calculation algorithm depends on the number of priorities defined for each tag.
For the Delete tag, the Priority is 5, and in the case of PriorityKey calculation for 10 Delete tags in one row sequentially
the PriorityKey value will be - 5 4 6 3 7 2 8 1 9 0. This is incorrect behavior, and this MR presents a solution that sorts tags based on the main priority of the tag. For all tags except delete, the execution order of tags with the same priority is assumed from 1 cell to the last, when for delete tags the execution order from the last cell to the first is assumed.