X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/IndentAction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/IndentAction.java index ce26e9b..cf03914 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/IndentAction.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/actions/IndentAction.java @@ -26,7 +26,9 @@ import net.sourceforge.phpeclipse.phpeditor.PHPEditor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; -import org.eclipse.jface.text.Assert; +//incastrix +//import org.eclipse.jface.text.Assert; +import org.eclipse.core.runtime.Assert; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DocumentCommand; import org.eclipse.jface.text.IDocument; @@ -86,9 +88,12 @@ public class IndentAction extends TextEditorAction { * @param isTabAction * whether the action should insert tabs if over the indentation */ - public IndentAction(ResourceBundle bundle, String prefix, - ITextEditor editor, boolean isTabAction) { - super(bundle, prefix, editor); + public IndentAction (ResourceBundle bundle, + String prefix, + ITextEditor editor, + boolean isTabAction) { + super (bundle, prefix, editor); + fIsTabAction = isTabAction; } @@ -405,10 +410,7 @@ public class IndentAction extends TextEditorAction { else { int size = 0; int l = indent.length(); - int tabSize = PHPeclipsePlugin - .getDefault() - .getPreferenceStore() - .getInt( + int tabSize = PHPeclipsePlugin.getDefault().getPreferenceStore().getInt( AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); for (int i = 0; i < l; i++) @@ -477,15 +479,19 @@ public class IndentAction extends TextEditorAction { */ private boolean isValidSelection() { ITextSelection selection = getSelection(); - if (selection.isEmpty()) + + if (selection.isEmpty()) { return false; + } int offset = selection.getOffset(); int length = selection.getLength(); IDocument document = getDocument(); - if (document == null) + + if (document == null) { return false; + } try { IRegion firstLine = document.getLineInformationOfOffset(offset); @@ -494,12 +500,17 @@ public class IndentAction extends TextEditorAction { // either the selection has to be empty and the caret in the WS at // the line start // or the selection has to extend over multiple lines - if (length == 0) - return document.get(lineOffset, offset - lineOffset).trim() - .length() == 0; - else + if (length == 0) { + boolean bRet; + + bRet = document.get (lineOffset, offset - lineOffset).trim().length() == 0; + + return bRet; + } + else { // return lineOffset + firstLine.getLength() < offset + length; return false; // only enable for empty selections for now + } } catch (BadLocationException e) { } @@ -528,17 +539,16 @@ public class IndentAction extends TextEditorAction { * * @return the current document or null */ - private IDocument getDocument() { - - ITextEditor editor = getTextEditor(); + private IDocument getDocument() { ITextEditor editor = getTextEditor(); if (editor != null) { - IDocumentProvider provider = editor.getDocumentProvider(); IEditorInput input = editor.getEditorInput(); - if (provider != null && input != null) + + if (provider != null && input != null) { return provider.getDocument(input); - + } } + return null; }