mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
same policy for choosing selected text editor suitable for navigation
This commit is contained in:
@@ -128,13 +128,8 @@ public abstract class GotoActionBase extends AnAction {
|
||||
return Pair.create(predefined, 0);
|
||||
}
|
||||
if (useEditorSelection) {
|
||||
final Editor editor = e.getData(CommonDataKeys.EDITOR);
|
||||
if (editor != null) {
|
||||
final String selectedText = editor.getSelectionModel().getSelectedText();
|
||||
if (selectedText != null && !selectedText.contains("\n")) {
|
||||
return Pair.create(selectedText, 0);
|
||||
}
|
||||
}
|
||||
String selectedText = getInitialTextForNavigation(e.getData(CommonDataKeys.EDITOR));
|
||||
if (selectedText != null) return new Pair<>(selectedText, 0);
|
||||
}
|
||||
|
||||
final String query = e.getData(SpeedSearchSupply.SPEED_SEARCH_CURRENT_QUERY);
|
||||
@@ -160,6 +155,17 @@ public abstract class GotoActionBase extends AnAction {
|
||||
return Pair.create("", 0);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getInitialTextForNavigation(@Nullable Editor editor) {
|
||||
if (editor != null) {
|
||||
final String selectedText = editor.getSelectionModel().getSelectedText();
|
||||
if (selectedText != null && !selectedText.contains("\n")) {
|
||||
return selectedText;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected <T> void showNavigationPopup(AnActionEvent e, ChooseByNameModel model, final GotoActionCallback<T> callback) {
|
||||
showNavigationPopup(e, model, callback, true);
|
||||
}
|
||||
|
||||
@@ -372,11 +372,8 @@ public class SearchEverywhereAction extends AnAction implements CustomComponentA
|
||||
mySkipFocusGain = false;
|
||||
return;
|
||||
}
|
||||
String text = "";
|
||||
if (myEditor != null) {
|
||||
text = myEditor.getSelectionModel().getSelectedText();
|
||||
text = text == null ? "" : text.trim();
|
||||
}
|
||||
String text = GotoActionBase.getInitialTextForNavigation(myEditor);
|
||||
text = text != null ? text.trim() : "";
|
||||
|
||||
search.setText(text);
|
||||
search.getTextEditor().setForeground(UIUtil.getLabelForeground());
|
||||
|
||||
Reference in New Issue
Block a user