mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-39406 Make multiline string with prefix be folded with the prefix
GitOrigin-RevId: e1fa6861d85916a0862fefc7342a34d3b0905281
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cfa826f9b6
commit
d34338e85d
@@ -207,15 +207,16 @@ public class PythonFoldingBuilder extends CustomFoldingBuilder implements DumbAw
|
||||
}
|
||||
if (node.getElementType() == PyElementTypes.STRING_LITERAL_EXPRESSION) {
|
||||
PyStringLiteralExpression stringLiteralExpression = (PyStringLiteralExpression)node.getPsi();
|
||||
String prefix = stringLiteralExpression.getStringElements().get(0).getPrefix();
|
||||
if (stringLiteralExpression.isDocString()) {
|
||||
final String stringValue = stringLiteralExpression.getStringValue().trim();
|
||||
final String[] lines = LineTokenizer.tokenize(stringValue, true);
|
||||
if (lines.length > 2 && lines[1].trim().length() == 0) {
|
||||
return "\"\"\"" + lines[0].trim() + "...\"\"\"";
|
||||
return prefix + "\"\"\"" + lines[0].trim() + "...\"\"\"";
|
||||
}
|
||||
return "\"\"\"...\"\"\"";
|
||||
return prefix + "\"\"\"...\"\"\"";
|
||||
} else {
|
||||
return getLanguagePlaceholderForString(stringLiteralExpression);
|
||||
return prefix + getLanguagePlaceholderForString(stringLiteralExpression);
|
||||
}
|
||||
}
|
||||
return "...";
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
def foo():<fold text='...'>
|
||||
<fold text='r"""..."""'>r"""
|
||||
foo/bar
|
||||
"""</fold>
|
||||
pass</fold>
|
||||
|
||||
mline = <fold text='u"..."'>u"\n\n\n\n\n\n\n\n" \
|
||||
"\n\n\n\n\n\n\n\"</fold>
|
||||
@@ -112,4 +112,9 @@ public class PyFoldingTest extends PyTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PY-39406
|
||||
public void testStringPrefixFolding() {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user