diff --git a/java/java-tests/testSrc/com/intellij/find/FindInEditorMultiCaretTest.java b/java/java-tests/testSrc/com/intellij/find/FindInEditorMultiCaretTest.java
index a8c4f255248b..dde048386828 100644
--- a/java/java-tests/testSrc/com/intellij/find/FindInEditorMultiCaretTest.java
+++ b/java/java-tests/testSrc/com/intellij/find/FindInEditorMultiCaretTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2014 JetBrains s.r.o.
+ * Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -135,6 +135,18 @@ public class FindInEditorMultiCaretTest extends LightPlatformCodeInsightFixtureT
"abc\n" +
"abc");
}
+
+ public void testFindNextRetainsOnlyOneCaretIfNotUsedAsMoveToNextOccurrence() throws Exception {
+ init("To be or not to be?");
+ initFind();
+ setTextToFind("be");
+ checkResultByText("To be or not to be?");
+ closeFind();
+ new EditorMouseFixture((EditorImpl)myFixture.getEditor()).alt().shift().clickAt(0, 8); // adding second caret
+ checkResultByText("To be or not to be?");
+ nextOccurrenceFromEditor();
+ checkResultByText("To be or not to be?");
+ }
private void setTextToFind(String text) {
EditorSearchSession editorSearchSession = getEditorSearchComponent();
@@ -198,7 +210,7 @@ public class FindInEditorMultiCaretTest extends LightPlatformCodeInsightFixtureT
}
private void initFind() {
- myFixture.performEditorAction("Find");
+ myFixture.performEditorAction(IdeActions.ACTION_FIND);
}
private EditorSearchSession getEditorSearchComponent() {
diff --git a/platform/lang-impl/src/com/intellij/find/impl/FindManagerImpl.java b/platform/lang-impl/src/com/intellij/find/impl/FindManagerImpl.java
index d66ec39b8fcf..88ca711539cd 100644
--- a/platform/lang-impl/src/com/intellij/find/impl/FindManagerImpl.java
+++ b/platform/lang-impl/src/com/intellij/find/impl/FindManagerImpl.java
@@ -954,6 +954,7 @@ public class FindManagerImpl extends FindManager {
if (fileEditor instanceof TextEditor) {
TextEditor textEditor = (TextEditor)fileEditor;
Editor editor = textEditor.getEditor();
+ editor.getCaretModel().removeSecondaryCarets();
if (tryToFindNextUsageViaEditorSearchComponent(editor, direction)) {
return true;
}