mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
paste the last \n into gstring
This commit is contained in:
+4
-3
@@ -144,9 +144,10 @@ public class StringLiteralCopyPasteProcessor implements CopyPastePreProcessor {
|
||||
@NonNls String breaker = getLineBreaker(token);
|
||||
final String[] lines = LineTokenizer.tokenize(text.toCharArray(), false, true);
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
String line = lines[i];
|
||||
buffer.append(escapeCharCharacters(line, token, escapeSlashes));
|
||||
if (i != lines.length - 1) buffer.append(breaker);
|
||||
buffer.append(escapeCharCharacters(lines[i], token, escapeSlashes));
|
||||
if (i != lines.length - 1 || "\n".equals(breaker) && text.endsWith("\n")) {
|
||||
buffer.append(breaker);
|
||||
}
|
||||
}
|
||||
text = buffer.toString();
|
||||
}
|
||||
|
||||
@@ -86,4 +86,18 @@ Foo f'''
|
||||
doTest 'a.txt', '<selection>a\nd</selection>', 'def x = "smth<caret>"', 'def x = "smtha\\n" +\n "d<caret>"'
|
||||
}
|
||||
|
||||
public void testGStringEolReplace() throws Exception {
|
||||
doTest 'a.txt',
|
||||
'''<selection>first
|
||||
second
|
||||
</selection>''',
|
||||
'''def x = """
|
||||
<selection>foo
|
||||
</selection>"""''',
|
||||
'''def x = """
|
||||
first
|
||||
second
|
||||
<caret>"""'''
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user