correction 3 for indentation by selection
Sylvestre Koumar [Thu, 17 Sep 2009 08:25:24 +0000 (10:25 +0200)]
scilab/modules/xpad/src/java/org/scilab/modules/xpad/style/ScilabStyleDocument.java

index 01ff88c..98db667 100644 (file)
@@ -529,12 +529,32 @@ public class ScilabStyleDocument extends DefaultStyledDocument implements Docume
                        }
                }
                
-               try {
+               if (autoIndent) {
+                       int  caretPosition = editor.getTextPane().getCaretPosition();
+                       try {
+                               if (editor.getTextPane().getText(caretPosition-1, 1).equals("\n")) {
+
+
+                                       //try {
+                                       applyIndent(lineStartPosition, lineEndPosition, tab);
+                                       tab = "";
+                                       //} catch (BadLocationException e) {
+                                       //e.printStackTrace();
+                                       //}
+
+                               }
+                       } catch (BadLocationException e) {
+                               e.printStackTrace();
+                       }
+               } else {
+                       try {
                        applyIndent(lineStartPosition, lineEndPosition, tab);
                        tab = "";
-               } catch (BadLocationException e) {
+                       } catch (BadLocationException e) {
                        e.printStackTrace();
+                       }
                }
+               
 
        }