diff --git a/python/src/com/jetbrains/python/codeInsight/intentions/PyQuotedStringIntention.java b/python/src/com/jetbrains/python/codeInsight/intentions/PyQuotedStringIntention.java index 56f6fb530ebf..9e82f66286f7 100644 --- a/python/src/com/jetbrains/python/codeInsight/intentions/PyQuotedStringIntention.java +++ b/python/src/com/jetbrains/python/codeInsight/intentions/PyQuotedStringIntention.java @@ -89,7 +89,7 @@ public class PyQuotedStringIntention extends BaseIntentionAction { else if (ch == '\'') { stringBuilder.append("\\\'"); } - else if (ch == '\\' && charArr[i+1] == '\"') { + else if (ch == '\\' && charArr[i+1] == '\"' && !(i+2 == charArr.length)) { skipNext = true; stringBuilder.append(charArr[i+1]); } @@ -119,7 +119,7 @@ public class PyQuotedStringIntention extends BaseIntentionAction { else if (ch == '"') { stringBuilder.append("\\\""); } - else if (ch == '\\' && charArr[i+1] == '\'') { + else if (ch == '\\' && charArr[i+1] == '\'' && !(i+2 == charArr.length)) { skipNext = true; stringBuilder.append(charArr[i+1]); } diff --git a/python/testData/intentions/afterQuotedStringDoubleSlash.py b/python/testData/intentions/afterQuotedStringDoubleSlash.py new file mode 100644 index 000000000000..64799d5c6f6b --- /dev/null +++ b/python/testData/intentions/afterQuotedStringDoubleSlash.py @@ -0,0 +1 @@ +data_path = dirname(realpath(__file__)).replace("\\", '/') \ No newline at end of file diff --git a/python/testData/intentions/beforeQuotedStringDoubleSlash.py b/python/testData/intentions/beforeQuotedStringDoubleSlash.py new file mode 100644 index 000000000000..b6bc075cbb51 --- /dev/null +++ b/python/testData/intentions/beforeQuotedStringDoubleSlash.py @@ -0,0 +1 @@ +data_path = dirname(realpath(__file__)).replace('\\', '/') \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyIntentionTest.java b/python/testSrc/com/jetbrains/python/PyIntentionTest.java index 30a6fcd00d42..6a21242632eb 100644 --- a/python/testSrc/com/jetbrains/python/PyIntentionTest.java +++ b/python/testSrc/com/jetbrains/python/PyIntentionTest.java @@ -149,6 +149,10 @@ public class PyIntentionTest extends PyLightFixtureTestCase { doTest(PyBundle.message("INTN.quoted.string.double.to.single")); } + public void testQuotedStringDoubleSlash() { //PY-3295 + doTest(PyBundle.message("INTN.quoted.string.single.to.double")); + } + public void testEscapedQuotedString() { //PY-2656 doTest(PyBundle.message("INTN.quoted.string.single.to.double")); }