From e11bdc863ba56039e5b3e5359fee90f150d1f9b1 Mon Sep 17 00:00:00 2001 From: Michael James Gratton Date: Sun, 1 Jul 2018 14:39:37 +1000 Subject: [PATCH] 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. --- .../imap/command/imap-search-command.vala | 25 ++++++++--------- .../imap/parameter/imap-list-parameter.vala | 27 +++++-------------- 2 files changed, 20 insertions(+), 32 deletions(-) diff --git a/src/engine/imap/command/imap-search-command.vala b/src/engine/imap/command/imap-search-command.vala index 23cf29a0..8738d1b7 100644 --- a/src/engine/imap/command/imap-search-command.vala +++ b/src/engine/imap/command/imap-search-command.vala @@ -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); } } - diff --git a/src/engine/imap/parameter/imap-list-parameter.vala b/src/engine/imap/parameter/imap-list-parameter.vala index 71dfd1e8..133d0d96 100644 --- a/src/engine/imap/parameter/imap-list-parameter.vala +++ b/src/engine/imap/parameter/imap-list-parameter.vala @@ -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 to_append = listp.list; - listp.list = new Gee.ArrayList(); - - 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); } /**