From: axelcl Date: Mon, 10 Apr 2006 18:15:42 +0000 (+0000) Subject: #1467296 patch for bug #1454529 X-Git-Url: http://git.phpeclipse.com #1467296 patch for bug #1454529 - when typing a { a closing } is added; - if a carriage return (enter) is inserted between the {} the closing brace is moved to the new appropriate position and the cursor is moved to the new indented position; - if the carriage return is inserted after the { but there is no } to the right, no extra } is added. --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java index f421323..8a88ecf 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPUnitEditor.java @@ -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;