mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed braces escaping for new-style formatted strings (PY-8372)
This commit is contained in:
@@ -145,8 +145,8 @@ public class PyStringFormatParser {
|
||||
final int n = s.length();
|
||||
while (pos < n) {
|
||||
int next = s.indexOf('{', pos);
|
||||
while (next > 0 && s.charAt(next - 1) == '\\') {
|
||||
next = s.indexOf('{', next + 1);
|
||||
while (next > 0 && next < n - 1 && s.charAt(next + 1) == '{') {
|
||||
next = s.indexOf('{', next + 2);
|
||||
}
|
||||
if (next < 0) {
|
||||
break;
|
||||
@@ -156,8 +156,8 @@ public class PyStringFormatParser {
|
||||
}
|
||||
pos = next;
|
||||
next = s.indexOf('}', pos);
|
||||
while (next > 0 && s.charAt(next - 1) == '\\') {
|
||||
next = s.indexOf('}', next + 1);
|
||||
while (next > 0 && next < n - 1 && s.charAt(next + 1) == '}') {
|
||||
next = s.indexOf('}', next + 2);
|
||||
}
|
||||
if (next > pos) {
|
||||
// TODO: Parse substitution details
|
||||
|
||||
@@ -119,4 +119,11 @@ public class PyStringFormatParserTest extends TestCase {
|
||||
assertEquals(TextRange.create(1, 6), chunks.get(0).getTextRange());
|
||||
assertEquals(TextRange.create(6, 11), chunks.get(1).getTextRange());
|
||||
}
|
||||
|
||||
// PY-8372
|
||||
public void testBracesEscaping() {
|
||||
final List<SubstitutionChunk> chunks = filterSubstitutions(parseNewStyleFormat("\\{\\}, {{}}"));
|
||||
assertEquals(1, chunks.size());
|
||||
assertEquals(TextRange.create(1, 4), chunks.get(0).getTextRange());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user