From 6d971285b05ccba4639ff98bf937e5d2aa49706e Mon Sep 17 00:00:00 2001 From: axelcl Date: Mon, 10 Apr 2006 18:15:42 +0000 Subject: [PATCH] #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. --- .../phpeclipse/phpeditor/PHPUnitEditor.java | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) 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; -- 1.7.1