IDEA-212529 Find/Find&Replace in path with newline always matches all whitespace at the beginning on subsequent line,

disregarding the search pattern

GitOrigin-RevId: c4c8fbae9b97b0fc8f6ae52c0b746203461a7f72
This commit is contained in:
Vassiliy.Kudryashov
2020-11-02 17:26:33 +00:00
committed by intellij-monorepo-bot
parent 1639e3cedd
commit 8d60f5808e
2 changed files with 3 additions and 4 deletions
@@ -999,7 +999,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
FindModel findModel = FindManagerTestUtils.configureFindModel("System.currentTimeMillis();\n System.currentTimeMillis();");
findModel.setMultiline(true);
String fileContent = "System.currentTimeMillis();\n System.currentTimeMillis();\n\n" +
" System.currentTimeMillis();\n System.currentTimeMillis();";
" System.currentTimeMillis();\n System.currentTimeMillis();";
FindResult findResult = myFindManager.findString(fileContent, 0, findModel, null);
assertTrue(findResult.isStringFound());
findResult = myFindManager.findString(fileContent, findResult.getEndOffset(), findModel, null);
@@ -1010,7 +1010,7 @@ public class FindManagerTest extends DaemonAnalyzerTestCase {
String text = "final override val\n" +
" d1PrimitiveType by lazyThreadSafeIdempotentGenerator { D1PrimitiveType( typeManager = this ) }";
String pattern = "final override val\n" +
"d(\\w+)PrimitiveType by lazyThreadSafeIdempotentGenerator \\{ D(\\w+)PrimitiveType\\( typeManager = this \\) \\}";
"\\s+d(\\w+)PrimitiveType by lazyThreadSafeIdempotentGenerator \\{ D(\\w+)PrimitiveType\\( typeManager = this \\) \\}";
String replacement = "";
FindModel findModel = FindManagerTestUtils.configureFindModel(pattern);
@@ -446,10 +446,9 @@ public final class FindManagerImpl extends FindManager {
if (findmodel.isRegularExpressions()) {
newStringToFind = StringUtil.replace(s, "\\n", "\n"); // temporary convert back escaped symbols
newStringToFind = newStringToFind.replaceAll( "\n", "\\\\n\\\\s*"); // add \\s* for convenience
newStringToFind = newStringToFind.replaceAll( "\n", "\\\\n");
} else {
newStringToFind = StringUtil.escapeToRegexp(s);
newStringToFind = newStringToFind.replaceAll("\\\\n\\s*", "\\\\n\\\\s*");
model.setRegularExpressions(true);
}
model.setStringToFind(newStringToFind);