paste the last \n into gstring

This commit is contained in:
peter
2011-11-23 09:56:53 +01:00
parent 0900779ebe
commit c1242b0c71
2 changed files with 18 additions and 3 deletions
@@ -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>"""'''
}
}