#1467296 patch for bug #1454529
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / PHPUnitEditor.java
index f421323..8a88ecf 100644 (file)
@@ -1014,6 +1014,12 @@ public class PHPUnitEditor extends PHPEditor { //implements
                        if (hasIdentifierToTheRight(document, offset + length))
                          return;
                  // fall through
+                 case '{':
+                               if (!fCloseBracketsPHP)
+                                 return;
+                               if (hasIdentifierToTheRight(document, offset + length))
+                                 return;
+                         // fall through
                  case '"':
                        if (event.character == '"') {
                          if (!fCloseStringsPHPDQ)
@@ -1093,7 +1099,7 @@ public class PHPUnitEditor extends PHPEditor { //implements
                        if (!fCloseBracketsPHP) {
                          return;
                        }
-                         if (hasCharacterToTheLeft(document,offset,'{')) {
+                         if (hasCharacterToTheLeft(document,offset,'{') && hasCharacterToTheRight(document,offset,'}')) {
                                  String lineDelimiter=StubUtility.getLineDelimiterFor(document);
                                  int caretPos=sourceViewer.getTextWidget().getCaretOffset();
                                final StringBuffer buffer = new StringBuffer(lineDelimiter);
@@ -1114,7 +1120,6 @@ public class PHPUnitEditor extends PHPEditor { //implements
                                int cursorPos=buffer.length();
                                buffer.append(lineDelimiter);
                                buffer.append(indent);
-                               buffer.append("}");
                                document.replace(offset, length, buffer.toString());
                                sourceViewer.getTextWidget().setCaretOffset(caretPos+cursorPos);
                                event.doit = false;