Rename ListParameter.append to extend and make it work as expected.

I.e. Don't modify the list being appended from, so that when the
ServerSearchEmail replay op is re-executed after a network error, the
search criteria have not disappeared.
This commit is contained in:
Michael James Gratton 2018-07-01 14:39:37 +10:00
parent d99e16e139
commit e11bdc863b
2 changed files with 20 additions and 32 deletions

View file

@ -13,21 +13,22 @@
public class Geary.Imap.SearchCommand : Command {
public const string NAME = "search";
public const string UID_NAME = "uid search";
public SearchCommand(SearchCriteria criteria) {
base (NAME);
// append rather than add the criteria, so the top-level criterion appear in the top-level
// list and not as a child list
append(criteria);
base(NAME);
// Extend rather than append the criteria, so the top-level
// criterion appear in the top-level list and not as a child
// list
extend(criteria);
}
public SearchCommand.uid(SearchCriteria criteria) {
base (UID_NAME);
// append rather than add the criteria, so the top-level criterion appear in the top-level
// list and not as a child list
append(criteria);
// Extend rather than append the criteria, so the top-level
// criterion appear in the top-level list and not as a child
// list
extend(criteria);
}
}

View file

@ -97,9 +97,9 @@ public class Geary.Imap.ListParameter : Geary.Imap.Parameter {
return count;
}
/**
* Appends the {@link ListParameter} to the end of this ListParameter.
* Adds all elements in the given list to the end of this list.
*
* The difference between this call and {@link add} is that add() will simply insert the
* {@link Parameter} to the tail of the list. Thus, add(ListParameter) will add a child list
@ -107,29 +107,16 @@ public class Geary.Imap.ListParameter : Geary.Imap.Parameter {
*
* (one two (three))
*
* append(ListParameter("three")) adds each element of the ListParameter to this one, not
* Instead, extend(ListParameter("three")) adds each element of the ListParameter to this one, not
* creating a child:
*
* (one two three)
*
* Thus, each element of the list is moved ("adopted") by this list, and the supplied list
* returns empty. This is slightly different than {@link adopt_children}, which preserves the
* list structure.
*
* @return Number of added elements. append() will not abort if an element fails to add.
* @return Number of added elements. This will not abort if an
* element fails to be added.
*/
public int append(ListParameter listp) {
// snap the child list off the supplied ListParameter so it's wiped clean
Gee.List<Parameter> to_append = listp.list;
listp.list = new Gee.ArrayList<Parameter>();
int count = 0;
foreach (Parameter param in to_append) {
if (add(param))
count++;
}
return count;
public int extend(ListParameter listp) {
return add_all(listp.list);
}
/**