IDEA-121057 Multiple Carets: Alt-N works in "whole word" mode if the whole word is initially selected

This commit is contained in:
Dmitry Batrak
2014-02-25 18:53:34 +04:00
parent cbbae06bbc
commit 1be8e04838
2 changed files with 10 additions and 31 deletions
@@ -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) {
@@ -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");