mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-121057 Multiple Carets: Alt-N works in "whole word" mode if the whole word is initially selected
This commit is contained in:
+4
-9
@@ -58,7 +58,7 @@ public class SelectNextOccurrenceAction extends EditorAction {
|
||||
caret.getOffset(),
|
||||
SelectWordUtil.JAVA_IDENTIFIER_PART_CONDITION);
|
||||
boolean notFoundPreviously = getAndResetNotFoundStatus(editor);
|
||||
Boolean wholeWordSearch = isWholeWordSearch(editor);
|
||||
boolean wholeWordSearch = isWholeWordSearch(editor);
|
||||
if (caret.hasSelection()) {
|
||||
Project project = editor.getProject();
|
||||
String selectedText = caret.getSelectedText();
|
||||
@@ -67,12 +67,6 @@ public class SelectNextOccurrenceAction extends EditorAction {
|
||||
}
|
||||
FindManager findManager = FindManager.getInstance(project);
|
||||
|
||||
if (wholeWordSearch == null) {
|
||||
wholeWordSearch = wordSelectionRange != null
|
||||
&& wordSelectionRange.getStartOffset() == caret.getSelectionStart()
|
||||
&& wordSelectionRange.getEndOffset() == caret.getSelectionEnd();
|
||||
setWholeWordSearch(editor, wholeWordSearch);
|
||||
}
|
||||
FindModel model = new FindModel();
|
||||
model.setStringToFind(caret.getSelectedText());
|
||||
model.setCaseSensitive(true);
|
||||
@@ -137,11 +131,12 @@ public class SelectNextOccurrenceAction extends EditorAction {
|
||||
editor.putUserData(NOT_FOUND, Boolean.TRUE);
|
||||
}
|
||||
|
||||
private static Boolean isWholeWordSearch(Editor editor) {
|
||||
private static boolean isWholeWordSearch(Editor editor) {
|
||||
if (!isRepeatedActionInvocation()) {
|
||||
editor.putUserData(WHOLE_WORDS, null);
|
||||
}
|
||||
return editor.getUserData(WHOLE_WORDS);
|
||||
Boolean value = editor.getUserData(WHOLE_WORDS);
|
||||
return value != null;
|
||||
}
|
||||
|
||||
private static void setWholeWordSearch(Editor editor, boolean isWholeWordSearch) {
|
||||
|
||||
+6
-22
@@ -58,6 +58,10 @@ public class SelectUnselectOccurrenceActionsTest extends LightPlatformCodeInsigh
|
||||
checkResult("some <selection>t<caret>ext</selection>\n" +
|
||||
"some texts\n" +
|
||||
"another text here");
|
||||
executeAction();
|
||||
checkResult("some <selection>t<caret>ext</selection>\n" +
|
||||
"some texts\n" +
|
||||
"another <selection>t<caret>ext</selection> here");
|
||||
assertEquals(0, hintCount);
|
||||
}
|
||||
|
||||
@@ -67,34 +71,29 @@ public class SelectUnselectOccurrenceActionsTest extends LightPlatformCodeInsigh
|
||||
"another text here");
|
||||
executeAction();
|
||||
checkResult("some <selection>t<caret>ext</selection>\n" +
|
||||
"some texts\n" +
|
||||
"another <selection>t<caret>ext</selection> here");
|
||||
"some <selection>t<caret>ext</selection>s\n" +
|
||||
"another text here");
|
||||
assertEquals(0, hintCount);
|
||||
}
|
||||
|
||||
public void testShowingHint() throws Exception {
|
||||
init("some <selection>t<caret>ext</selection>\n" +
|
||||
"some texts\n" +
|
||||
"another <selection>t<caret>ext</selection> here");
|
||||
executeAction();
|
||||
assertEquals(1, hintCount);
|
||||
checkResult("some <selection>t<caret>ext</selection>\n" +
|
||||
"some texts\n" +
|
||||
"another <selection>t<caret>ext</selection> here");
|
||||
executeAction();
|
||||
assertEquals(1, hintCount);
|
||||
checkResult("some <selection>t<caret>ext</selection>\n" +
|
||||
"some texts\n" +
|
||||
"another <selection>t<caret>ext</selection> here");
|
||||
}
|
||||
|
||||
public void testRevert() throws Exception {
|
||||
init("some <selection>t<caret>ext</selection>\n" +
|
||||
"some texts\n" +
|
||||
"another <selection>t<caret>ext</selection> here");
|
||||
executeReverseAction();
|
||||
checkResult("some <selection>t<caret>ext</selection>\n" +
|
||||
"some texts\n" +
|
||||
"another text here");
|
||||
assertEquals(0, hintCount);
|
||||
}
|
||||
@@ -141,21 +140,6 @@ public class SelectUnselectOccurrenceActionsTest extends LightPlatformCodeInsigh
|
||||
assertEquals(0, hintCount);
|
||||
}
|
||||
|
||||
public void testWholeWordinessIsRememberedAtStart() throws Exception {
|
||||
init("some <selection>text<caret></selection>s\n" +
|
||||
"another text\n" +
|
||||
"some other texts");
|
||||
executeAction();
|
||||
checkResult("some <selection>text<caret></selection>s\n" +
|
||||
"another <selection>text<caret></selection>\n" +
|
||||
"some other texts");
|
||||
executeAction();
|
||||
checkResult("some <selection>text<caret></selection>s\n" +
|
||||
"another <selection>text<caret></selection>\n" +
|
||||
"some other <selection>text<caret></selection>s");
|
||||
assertEquals(0, hintCount);
|
||||
}
|
||||
|
||||
public void testOccurrenceInCollapsedRegion() throws Exception {
|
||||
init("normal <selection><caret>line</selection>\n" +
|
||||
"collapsed line");
|
||||
|
||||
Reference in New Issue
Block a user