You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ne...@apache.org on 2023/10/31 19:29:47 UTC
(netbeans) branch delivery updated: [NETBEANS-6638]: Avoid adding a space after opening curly brace.
This is an automated email from the ASF dual-hosted git repository.
neilcsmith pushed a commit to branch delivery
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/delivery by this push:
new 0136307ef3 [NETBEANS-6638]: Avoid adding a space after opening curly brace.
new 7668ad1083 Merge pull request #6641 from lahodaj/NETBEANS-6638
0136307ef3 is described below
commit 0136307ef350e47ceab15cdb1bb4487802b2b853
Author: Jan Lahoda <ja...@oracle.com>
AuthorDate: Tue Oct 31 08:26:41 2023 +0100
[NETBEANS-6638]: Avoid adding a space after opening curly brace.
---
.../src/org/netbeans/modules/editor/java/TypingCompletion.java | 10 ++++++++--
.../netbeans/modules/editor/java/TypingCompletionUnitTest.java | 6 ++++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/java/java.editor/src/org/netbeans/modules/editor/java/TypingCompletion.java b/java/java.editor/src/org/netbeans/modules/editor/java/TypingCompletion.java
index 59340af52c..5f2172b49d 100644
--- a/java/java.editor/src/org/netbeans/modules/editor/java/TypingCompletion.java
+++ b/java/java.editor/src/org/netbeans/modules/editor/java/TypingCompletion.java
@@ -168,8 +168,10 @@ class TypingCompletion {
return;
}
+ char insChr = context.getText().charAt(0);
+
if (isString(currentToken)) {
- if (context.getOffset() >= 1 && context.getText().charAt(0) == '{') {
+ if (context.getOffset() >= 1 && insChr == '{') {
char chr = context.getDocument().getText(context.getOffset() - 1, 1).charAt(0);
if (chr == '\\') {
@@ -180,10 +182,14 @@ class TypingCompletion {
return ;
}
+ if (insChr == '{') {
+ //curly brace should only be matched in string templates:
+ return ;
+ }
+
char chr = context.getDocument().getText(context.getOffset(), 1).charAt(0);
if (chr == ')' || chr == ',' || chr == '\"' || chr == '\'' || chr == ' ' || chr == ']' || chr == '}' || chr == '\n' || chr == '\t' || chr == ';') {
- char insChr = context.getText().charAt(0);
context.setText("" + insChr + matching(insChr), 1); // NOI18N
}
}
diff --git a/java/java.editor/test/unit/src/org/netbeans/modules/editor/java/TypingCompletionUnitTest.java b/java/java.editor/test/unit/src/org/netbeans/modules/editor/java/TypingCompletionUnitTest.java
index 1b6ca11625..a0713d608f 100644
--- a/java/java.editor/test/unit/src/org/netbeans/modules/editor/java/TypingCompletionUnitTest.java
+++ b/java/java.editor/test/unit/src/org/netbeans/modules/editor/java/TypingCompletionUnitTest.java
@@ -1413,6 +1413,12 @@ public void testPositionInTextBlock() throws Exception {
ctx.assertDocumentTextEquals("\"\\{}|\"");
}
+ public void testX() throws Exception {
+ Context ctx = new Context(new JavaKit(), "");
+ ctx.typeChar('{');
+ ctx.assertDocumentTextEquals("{");
+ }
+
private boolean isInsideString(String code) throws BadLocationException {
int pos = code.indexOf('|');
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists