Skip to content

Commit ef096fd

Browse files
Maximilian WittmerMaximilian Wittmer
authored andcommitted
[FindNextAction] synchronize search history with FindReplaceOverlay
synchronize search history with the FindReplaceOverlay and FindReplaceDialog.
1 parent 7587ea1 commit ef096fd

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/HistoryStore.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,18 @@ public HistoryStore(IDialogSettings settingsManager, String sectionName, int his
4444
}
4545

4646
public Iterable<String> get() {
47+
loadSection(sectionName);
4748
return history;
4849
}
4950

5051
public String get(int index) {
52+
loadSection(sectionName);
5153
return history.get(index);
5254
}
5355

5456

5557
public void add(String historyItem) {
58+
loadSection(sectionName);
5659
if (sectionName == null) {
5760
throw new IllegalStateException("No section loaded"); //$NON-NLS-1$
5861
}
@@ -68,6 +71,7 @@ public void remove(String historyItem) {
6871
if (indexInHistory >= 0) {
6972
history.remove(indexInHistory);
7073
}
74+
writeHistory();
7175
}
7276

7377
public boolean isEmpty() {
@@ -110,10 +114,12 @@ private void writeHistory() {
110114
}
111115

112116
public int indexOf(String entry) {
117+
loadSection(sectionName);
113118
return history.indexOf(entry);
114119
}
115120

116121
public int size() {
122+
loadSection(sectionName);
117123
return history.size();
118124
}
119125
}

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/findandreplace/overlay/FindReplaceOverlay.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
7272

7373
import org.eclipse.ui.texteditor.AbstractTextEditor;
74+
import org.eclipse.ui.texteditor.FindReplaceAction;
7475
import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
7576
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
7677
import org.eclipse.ui.texteditor.StatusTextEditor;
@@ -230,7 +231,7 @@ private void asyncExecIfOpen(Runnable operation) {
230231
*/
231232
private static IDialogSettings getDialogSettings() {
232233
IDialogSettings settings = PlatformUI
233-
.getDialogSettingsProvider(FrameworkUtil.getBundle(FindReplaceOverlay.class)).getDialogSettings();
234+
.getDialogSettingsProvider(FrameworkUtil.getBundle(FindReplaceAction.class)).getDialogSettings();
234235
return settings;
235236
}
236237

@@ -542,8 +543,7 @@ private void createSearchBar() {
542543
searchBarContainer = new Composite(searchContainer, SWT.NONE);
543544
GridDataFactory.fillDefaults().grab(true, true).align(GridData.FILL, GridData.FILL).applyTo(searchBarContainer);
544545
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(searchBarContainer);
545-
546-
HistoryStore searchHistory = new HistoryStore(getDialogSettings(), "searchhistory", //$NON-NLS-1$
546+
HistoryStore searchHistory = new HistoryStore(getDialogSettings(), "findhistory", //$NON-NLS-1$
547547
HISTORY_SIZE);
548548
searchBar = new HistoryTextWrapper(searchHistory, searchBarContainer, SWT.SINGLE);
549549
searchBarDecoration = new ControlDecoration(searchBar, SWT.BOTTOM | SWT.LEFT);

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,10 @@ private int findAndSelect(int offset, String findString, boolean forwardSearch,
340340
* @return the dialog settings to be used
341341
*/
342342
private IDialogSettings getDialogSettings() {
343-
IDialogSettings settings = PlatformUI.getDialogSettingsProvider(FrameworkUtil.getBundle(FindNextAction.class))
343+
IDialogSettings settings = PlatformUI
344+
.getDialogSettingsProvider(FrameworkUtil.getBundle(FindReplaceAction.class))
344345
.getDialogSettings();
345-
fDialogSettings= settings.getSection(FindReplaceDialog.class.getName());
346-
if (fDialogSettings == null)
347-
fDialogSettings= settings.addNewSection(FindReplaceDialog.class.getName());
348-
return fDialogSettings;
346+
return settings;
349347
}
350348

351349
/**

bundles/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ private void setupSearchHistory() {
12781278
*/
12791279
private IDialogSettings getDialogSettings() {
12801280
IDialogSettings settings = PlatformUI
1281-
.getDialogSettingsProvider(FrameworkUtil.getBundle(FindReplaceDialog.class)).getDialogSettings();
1281+
.getDialogSettingsProvider(FrameworkUtil.getBundle(FindReplaceAction.class)).getDialogSettings();
12821282
fDialogSettings = settings.getSection(getClass().getName());
12831283
if (fDialogSettings == null)
12841284
fDialogSettings = settings.addNewSection(getClass().getName());

0 commit comments

Comments
 (0)