Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Aeschlimann2006-07-26 10:21:38 +0000
committerMartin Aeschlimann2006-07-26 10:21:38 +0000
commitea2d5af14c98cd88b3e89029e47a174fe102168b (patch)
tree0924cb903f6246d2b9e24a7dba121231039d9e82
parentb2e57a3a13cd960d3004a8ddd2030e24903cd645 (diff)
downloadeclipse.platform.text-ea2d5af14c98cd88b3e89029e47a174fe102168b.tar.gz
eclipse.platform.text-ea2d5af14c98cd88b3e89029e47a174fe102168b.tar.xz
eclipse.platform.text-ea2d5af14c98cd88b3e89029e47a174fe102168b.zip
142292 Unable to Searchr321_v20060726
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java10
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java17
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java6
3 files changed, 16 insertions, 17 deletions
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
index 64bf7bc0f..55acc1ee8 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/InternalSearchUI.java
@@ -301,13 +301,13 @@ public class InternalSearchUI {
}
public void addQuery(ISearchQuery query) {
- int historyLimit= SearchPreferencePage.getHistoryLimit();
+ int historyLimit= SearchPreferencePage.getHistoryLimit(); // guaranteed to be > 0
QueryManager searchManager= getSearchManager();
- while (searchManager.getQueries().length >= historyLimit) {
- ISearchQuery oldestQuery= searchManager.getOldestQuery();
- if (oldestQuery != null)
- removeQuery(oldestQuery);
+ ISearchQuery[] queries= searchManager.getQueries();
+
+ for (int i= historyLimit - 1; i < queries.length; i++) {
+ removeQuery(queries[i]);
}
searchManager.addQuery(query);
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java
index cfca906ae..80e71853c 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/QueryManager.java
@@ -31,13 +31,15 @@ class QueryManager {
fLRU= new ArrayList();
}
- synchronized boolean hasQueries() {
+ boolean hasQueries() {
return !fQueries.isEmpty();
}
- synchronized ISearchQuery[] getQueries() {
- ISearchQuery[] result= new ISearchQuery[fQueries.size()];
- return (ISearchQuery[]) fQueries.toArray(result);
+ ISearchQuery[] getQueries() {
+ synchronized (fQueries) {
+ ISearchQuery[] result= new ISearchQuery[fQueries.size()];
+ return (ISearchQuery[]) fQueries.toArray(result);
+ }
}
void removeQuery(ISearchQuery query) {
@@ -146,11 +148,4 @@ class QueryManager {
fLRU.add(0, query);
}
}
-
- ISearchQuery getOldestQuery() {
- if (fLRU.size() > 0)
- return (ISearchQuery) fLRU.get(fLRU.size()-1);
- return null;
- }
-
}
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
index a8a17c644..e6fba411d 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
@@ -360,7 +360,11 @@ public class SearchPreferencePage extends FieldEditorPreferencePage implements I
public static int getHistoryLimit() {
IPreferenceStore store= SearchPlugin.getDefault().getPreferenceStore();
- return store.getInt(LIMIT_HISTORY);
+ int limit= store.getInt(LIMIT_HISTORY);
+ if (limit > 0) {
+ return limit;
+ }
+ return 10; // default
}
}

Back to the top