Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bundles/org.eclipse.text.quicksearch/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.text.quicksearch;singleton:=true
Bundle-Version: 1.2.500.qualifier
Bundle-Version: 1.2.600.qualifier
Bundle-Activator: org.eclipse.text.quicksearch.internal.ui.QuickSearchActivator
Require-Bundle: org.eclipse.ui;bundle-version="[3.113.0,4.0.0)",
org.eclipse.core.resources;bundle-version="[3.13.0,4.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.LinkedList;
import java.util.List;

import org.eclipse.core.commands.AbstractHandler;
Expand Down Expand Up @@ -83,6 +85,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
Expand Down Expand Up @@ -296,13 +299,17 @@ public void update(ViewerCell cell) {
private static final String DIALOG_SASH_WEIGHTS = "SASH_WEIGHTS"; //$NON-NLS-1$

private static final String DIALOG_LAST_QUERY = "LAST_QUERY"; //$NON-NLS-1$
private static final String DIALOG_PATH_FILTER = "PATH_FILTER"; //$NON-NLS-1$
private static final String CASE_SENSITIVE = "CASE_SENSITIVE"; //$NON-NLS-1$
private static final boolean CASE_SENSITIVE_DEFAULT = true;

private static final String KEEP_OPEN = "KEEP_OPEN"; //$NON-NLS-1$
private static final boolean KEEP_OPEN_DEFAULT = false;

private final Deque<String> filterHistory = new LinkedList<>();

private static final int FILTER_HISTORY_SIZE = 5;

private static final String FILTER_HISTORY = "FILTER_HISTORY"; //$NON-NLS-1$
/**
* Represents an empty selection in the pattern input field (used only for
* initial pattern).
Expand Down Expand Up @@ -369,7 +376,7 @@ public void update(ViewerCell cell) {
private Label headerLabel;

private IWorkbenchWindow window;
private Text searchIn;
private Combo searchIn;
private Label listLabel;

/**
Expand Down Expand Up @@ -417,8 +424,16 @@ protected void restoreDialog(IDialogSettings settings) {
pattern.setText(lastSearch);
pattern.selectAll();
}
if (settings.get(DIALOG_PATH_FILTER)!=null) {
String filter = settings.get(DIALOG_PATH_FILTER);

// Retrieve the last locations where the user searched (works across restarts)
filterHistory.addAll(List.of(settings.getArray(FILTER_HISTORY)));
if (!filterHistory.isEmpty()) {
String filter = filterHistory.getFirst();

// Filter out blanks
filterHistory.removeIf(String::isBlank);

searchIn.setItems(filterHistory.toArray(String[]::new));
Comment on lines +431 to +436
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I don't think we need a comment to explain the next line

Suggested change
String filter = filterHistory.getFirst();
// Filter out blanks
filterHistory.removeIf(String::isBlank);
searchIn.setItems(filterHistory.toArray(String[]::new));
String filter = filterHistory.getFirst();
filterHistory.removeIf(String::isBlank);
searchIn.setItems(filterHistory.toArray(String[]::new));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd normally agree but seeing that the builds are so brittle, I'd like to leave it as it is.

searchIn.setText(filter);
}

Expand Down Expand Up @@ -452,6 +467,15 @@ protected void restoreDialog(IDialogSettings settings) {
}
}

private void inputNewSearchFilter(String searchIn) {
filterHistory.remove(searchIn);
filterHistory.addFirst(searchIn);

if (filterHistory.size() > FILTER_HISTORY_SIZE) {
filterHistory.removeLast();
}
}

private class ToggleKeepOpenAction extends Action {
public ToggleKeepOpenAction(IDialogSettings settings) {
super(
Expand Down Expand Up @@ -533,7 +557,10 @@ public boolean close() {
protected void storeDialog(IDialogSettings settings) {
String currentSearch = pattern.getText();
settings.put(DIALOG_LAST_QUERY, currentSearch);
settings.put(DIALOG_PATH_FILTER, searchIn.getText());

inputNewSearchFilter(searchIn.getText());
settings.put(FILTER_HISTORY, filterHistory.toArray(String[]::new));

if (toggleCaseSensitiveAction!=null) {
settings.put(CASE_SENSITIVE, toggleCaseSensitiveAction.isChecked());
}
Expand Down Expand Up @@ -755,7 +782,7 @@ public void getName(AccessibleEvent e) {
Label searchInLabel = new Label(searchInComposite, SWT.NONE);
searchInLabel.setText(Messages.QuickSearchDialog_In);
GridDataFactory.swtDefaults().indent(5, 0).applyTo(searchInLabel);
searchIn = new Text(searchInComposite, SWT.SINGLE | SWT.BORDER | SWT.ICON_CANCEL);
searchIn = new Combo(searchInComposite, SWT.SINGLE | SWT.BORDER | SWT.ICON_CANCEL);
searchIn.setToolTipText(Messages.QuickSearchDialog_InTooltip);
GridDataFactory.fillDefaults().grab(true, false).indent(5, 0).applyTo(searchIn);

Expand Down
Loading