This is an automated email from the ASF dual-hosted git repository.
lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 77828d84e0 #4556 - NetBeans should not auto-insert \n\ in Groovy
triple quoted strings (#4562)
77828d84e0 is described below
commit 77828d84e021af3c3df5999574f39c554ce83a46
Author: Petr Pisl <[email protected]>
AuthorDate: Wed Aug 31 01:50:02 2022 +0200
#4556 - NetBeans should not auto-insert \n\ in Groovy triple quoted strings
(#4562)
* #4556 - NetBeans should not auto-insert \n\ in Groovy triple quoted
strings
* ''' are handle as well.
---
.../typinghooks/GroovyTypedBreakInterceptor.java | 5 ++++
.../typinghooks/TypedBreakInterceptorTest.java | 28 ++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git
a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/typinghooks/GroovyTypedBreakInterceptor.java
b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/typinghooks/GroovyTypedBreakInterceptor.java
index 11e76f980a..7d5dd60872 100644
---
a/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/typinghooks/GroovyTypedBreakInterceptor.java
+++
b/groovy/groovy.editor/src/org/netbeans/modules/groovy/editor/typinghooks/GroovyTypedBreakInterceptor.java
@@ -163,6 +163,11 @@ public class GroovyTypedBreakInterceptor implements
TypedBreakInterceptor {
}
if (id == GroovyTokenId.STRING_LITERAL || id ==
GroovyTokenId.STRING_CH && offset < ts.offset()+ts.token().length()) {
+ String tokenText = token.text().toString();
+ if (id == GroovyTokenId.STRING_LITERAL
+ && (tokenText.startsWith("\"\"\"") ||
tokenText.startsWith("'''"))) {
+ return;
+ }
String str = (id != GroovyTokenId.STRING_LITERAL || offset >
ts.offset()) ? "\\n\\\n" : "\\\n";
context.setText(str, -1, str.length());
return;
diff --git
a/groovy/groovy.editor/test/unit/src/org/netbeans/modules/groovy/editor/typinghooks/TypedBreakInterceptorTest.java
b/groovy/groovy.editor/test/unit/src/org/netbeans/modules/groovy/editor/typinghooks/TypedBreakInterceptorTest.java
index 77c4b06d76..184469a15a 100644
---
a/groovy/groovy.editor/test/unit/src/org/netbeans/modules/groovy/editor/typinghooks/TypedBreakInterceptorTest.java
+++
b/groovy/groovy.editor/test/unit/src/org/netbeans/modules/groovy/editor/typinghooks/TypedBreakInterceptorTest.java
@@ -146,5 +146,33 @@ public class TypedBreakInterceptorTest extends
GroovyTestBase {
// No auto-// on new lines
insertBreak("foo // ^", "foo // \n^");
}
+
+ public void testStringLiteral01() throws Exception {
+ insertBreak("String a = \"\"\" ahoj^how are you? \"\"\"", "String a =
\"\"\" ahoj\n^how are you? \"\"\"");
+ }
+
+ public void testStringLiteral02() throws Exception {
+ insertBreak("\"\"\" ahoj^how are you?", "\"\"\" ahoj\n^how are you?");
+ }
+ public void testStringLiteral03() throws Exception {
+ insertBreak("\"\"\" ahoj^", "\"\"\" ahoj\n^");
+ }
+
+ public void testStringLiteral04() throws Exception {
+ insertBreak("String a = \" ahoj^how are you? \"", "String a = \"
ahoj\\n\\\n^how are you? \"");
+ }
+
+ public void testStringLiteral05() throws Exception {
+ insertBreak("String a = ''' ahoj^how are you? '''", "String a = '''
ahoj\n^how are you? '''");
+ }
+
+ public void testStringLiteral06() throws Exception {
+ insertBreak("''' ahoj^how are you?", "''' ahoj\n^how are you?");
+ }
+
+ public void testStringLiteral07() throws Exception {
+ insertBreak("''' ahoj^", "''' ahoj\n^");
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists