Author: mkrueger
Date: 2007-09-12 05:22:19 -0400 (Wed, 12 Sep 2007)
New Revision: 85670

Modified:
   trunk/monodevelop/Extras/CSharpBinding/ChangeLog
   trunk/monodevelop/Extras/CSharpBinding/Gui/CSharpTextEditorExtension.cs
Log:
* Gui/CSharpTextEditorExtension.cs: Fixed 82770: MonoDevelop should
  keep in comments when return is pressed.

Modified: trunk/monodevelop/Extras/CSharpBinding/ChangeLog
===================================================================
--- trunk/monodevelop/Extras/CSharpBinding/ChangeLog    2007-09-12 08:33:31 UTC 
(rev 85669)
+++ trunk/monodevelop/Extras/CSharpBinding/ChangeLog    2007-09-12 09:22:19 UTC 
(rev 85670)
@@ -1,5 +1,10 @@
 2007-09-12  Mike Krüger <[EMAIL PROTECTED]> 
 
+       * Gui/CSharpTextEditorExtension.cs: Fixed 82770: MonoDevelop should 
keep in
+         comments when return is pressed.
+
+2007-09-12  Mike Krüger <[EMAIL PROTECTED]> 
+
        * Gui/CSharpTextEditorExtension.cs: Fixed 82768: Move cursor after new
          summary comment.
 

Modified: 
trunk/monodevelop/Extras/CSharpBinding/Gui/CSharpTextEditorExtension.cs
===================================================================
--- trunk/monodevelop/Extras/CSharpBinding/Gui/CSharpTextEditorExtension.cs     
2007-09-12 08:33:31 UTC (rev 85669)
+++ trunk/monodevelop/Extras/CSharpBinding/Gui/CSharpTextEditorExtension.cs     
2007-09-12 09:22:19 UTC (rev 85670)
@@ -184,6 +184,7 @@
                                return base.KeyPress (key, modifier);
                        
                        switch (key) {
+                       
                        case Gdk.Key.greater:
                                
                                cursor = Editor.SelectionStartPosition;
@@ -271,6 +272,9 @@
                                
                                c = '\t';
                                break;
+                       case Gdk.Key.BackSpace:
+                               c = '\0';
+                               break;
                        default:
                                if ((c = (char) Gdk.Keyval.ToUnicode ((uint) 
key)) == 0) {
                                        cursor = Editor.SelectionStartPosition;
@@ -302,7 +306,15 @@
                                
                                engine.Push (ch);
                        }
-                       
+                       if (key == Gdk.Key.BackSpace) {
+                               bool emptyDocComment = 
engine.IsInsideDocLineComment && Editor.GetLineText (engine.LineNumber).Trim 
().Length == 3;
+                               bool emptyMutlilineComment = 
engine.IsInsideMultiLineComment && (Editor.GetLineText (engine.LineNumber).Trim 
().Length <= 1 ||Editor.GetLineText (engine.LineNumber).Trim () == 
"/*"||Editor.GetLineText (engine.LineNumber).Trim () == "/**");
+                               if (emptyDocComment || emptyMutlilineComment) {
+                                       Editor.InsertText (cursor, "\n");
+                                       Editor.DeleteLine (engine.LineNumber);
+                               }
+                               return base.KeyPress (key, modifier);
+                       }
                        if (c == '\n') {
                                // Pass off to base.KeyPress() so the '\n' gets 
added to the Undo stack, etc
                                nInserted = 0;
@@ -315,7 +327,7 @@
                                }
                                
                                bool inDoc = engine.IsInsideDocLineComment;
-                               bool emptyDocComment = inDoc && 
Editor.GetLineText (engine.LineNumber).Trim ().Length == 3;
+                               //bool emptyDocComment = inDoc && 
Editor.GetLineText (engine.LineNumber).Trim ().Length == 3;
                                engine.Push ('\n');
                                nInserted--;
                                cursor++;
@@ -325,6 +337,27 @@
                                        Editor.DeleteText (cursor, nInserted);
                                }
                                
+                               if (inDoc) {
+                                       Editor.InsertText (cursor, 
engine.ThisLineIndent + "/// ");
+                                       return true;
+                               }
+                               
+                               if (engine.IsInsideMultiLineComment) {
+                                       string indent = engine.ThisLineIndent;
+                                       if (engine.LineNumber > 0) {
+                                               string text = 
Editor.GetLineText (engine.LineNumber - 1);
+                                               if (text.Trim ().StartsWith 
("*")) {
+                                                       indent = text.Substring 
(0, text.IndexOf ('*'));
+                                               } else if (text.Trim 
().StartsWith ("/**")) {
+                                                       indent = text.Substring 
(0, text.IndexOf ("/**")) + "  ";
+                                               }
+                                       }
+                                       Editor.InsertText (cursor, indent + "* 
");
+                                       engine.Push ('*');
+                                       engine.Push (' ');
+                                       return true;
+                               }
+                       
                                ch = Editor.GetCharAt (cursor);
                                if (ch == 0 || ch == '\n') {
                                        // the simple case
@@ -334,23 +367,10 @@
                                                engine.Push (newIndent[i]);
                                        cursor += newIndent.Length;
                                        
-                                       if (engine.IsInsideMultiLineComment) {
-                                               Editor.InsertText (cursor, "* 
");
-                                               engine.Push ('*');
-                                               engine.Push (' ');
-                                       }
-                                       
-                                       if (inDoc && !emptyDocComment) {
-                                               Editor.InsertText (cursor, "/// 
");
-                                               engine.Push ('/');
-                                               engine.Push ('/');
-                                               engine.Push ('/');
-                                               engine.Push (' ');
-                                       }
-                                       
                                        // we handled the <Return>
                                        return true;
                                }
+                                       
                                
                                // need more context... fall thru
                        } else {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to