Changeset 6744 in josm for trunk/src/org


Ignore:
Timestamp:
2014-01-19T22:11:57+01:00 (11 years ago)
Author:
simon04
Message:

fix #8032 - Search history loses entries when re-using queries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r6742 r6744  
    2020import java.util.Collections;
    2121import java.util.HashSet;
     22import java.util.LinkedHashSet;
    2223import java.util.LinkedList;
    2324import java.util.List;
     
    100101        if(searchHistory.isEmpty() || !s.equals(searchHistory.getFirst())) {
    101102            searchHistory.addFirst(new SearchSetting(s));
     103        } else if (searchHistory.contains(s)) {
     104            // move existing entry to front, fixes #8032 - search history loses entries when re-using queries
     105            searchHistory.remove(s);
     106            searchHistory.addFirst(new SearchSetting(s));
    102107        }
    103108        int maxsize = Main.pref.getInteger("search.history-size", DEFAULT_SEARCH_HISTORY_SIZE);
     
    105110            searchHistory.removeLast();
    106111        }
    107         List<String> savedHistory = new ArrayList<String>(searchHistory.size());
     112        LinkedHashSet<String> savedHistory = new LinkedHashSet<String>(searchHistory.size());
    108113        for (SearchSetting item: searchHistory) {
    109114            savedHistory.add(item.writeToString());
Note: See TracChangeset for help on using the changeset viewer.