[Pydev-cvs] org.python.pydev/src/org/python/pydev/editor/autoedit PyAutoIndentStrategy.java,1.24,1.2
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2006-03-15 00:18:42
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/autoedit In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25728/src/org/python/pydev/editor/autoedit Modified Files: PyAutoIndentStrategy.java Log Message: Index: PyAutoIndentStrategy.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/autoedit/PyAutoIndentStrategy.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** PyAutoIndentStrategy.java 14 Mar 2006 19:31:19 -0000 1.24 --- PyAutoIndentStrategy.java 15 Mar 2006 00:18:37 -0000 1.25 *************** *** 7,12 **** package org.python.pydev.editor.autoedit; - import java.util.HashMap; - import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy; --- 7,10 ---- *************** *** 59,67 **** private String autoIndentNewline(IDocument document, int length, String text, int offset) throws BadLocationException { - HashMap<String, Object> locals = new HashMap<String, Object>(); - locals.put("text",text); - JythonPlugin.exec(locals, "indent.py", interpreter); ! if (length == 0 && text != null && AbstractIndentPrefs.endsWithNewline(document, text)) { if (offset > 0) { --- 57,62 ---- private String autoIndentNewline(IDocument document, int length, String text, int offset) throws BadLocationException { ! if (isNewLineText(document, length, text)) { if (offset > 0) { *************** *** 101,108 **** } } - - - - } } --- 96,99 ---- *************** *** 111,114 **** --- 102,115 ---- } + /** + * @param document + * @param length + * @param text + * @return + */ + private boolean isNewLineText(IDocument document, int length, String text) { + return length == 0 && text != null && AbstractIndentPrefs.endsWithNewline(document, text); + } + public static final String[] DEDENT_TOKENS = new String[]{ "return", *************** *** 159,164 **** --- 160,186 ---- */ public void customizeDocumentCommand(IDocument document, DocumentCommand command) { + // I was going to do some things in jython here, but there is too much code around for that... + // HashMap<String, Object> locals = new HashMap<String, Object>(); + // locals.put("cmd",command); + // locals.put("doc",document); + // locals.put("prefs",getIndentPrefs()); + // locals.put("strategy",this); + // if(JythonPlugin.exec(locals, "indent.py", interpreter) == true){ + // //ok, it has already executed what was needed, so, let's return + // return; + // } + // // super idents newlines the same amount as the previous line super.customizeDocumentCommand(document, command); + + String contentType = ParsingUtils.getContentType(document.get(), command.offset); + if(!contentType.equals( ParsingUtils.PY_DEFAULT)){ + //the indentation is only valid for things in the code (comments should not be indented). + //(that is, if it is not a new line... in this case, it may have to be indented) + if(!isNewLineText(document, command.length, command.text)){ + return; + } + } + try { *************** *** 298,303 **** throw new RuntimeException(e); } - } /** * This function makes the else auto-dedent (if available) --- 320,325 ---- throw new RuntimeException(e); } } + /** * This function makes the else auto-dedent (if available) *************** *** 391,397 **** } ! while (spaceSteps >= 0){ ! spaceSteps -= 1; ! b.append(" "); } --- 413,421 ---- } ! if(prefs.getUseSpaces()){ ! while (spaceSteps >= 0){ ! spaceSteps -= 1; ! b.append(" "); ! } } |