Author: mhutch
Date: 2008-02-06 19:11:48 -0500 (Wed, 06 Feb 2008)
New Revision: 95101

Modified:
   trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor/ChangeLog
   
trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorBuffer.cs
   
trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.addin.xml
   trunk/monodevelop/main/src/addins/SourceEditor2/ChangeLog
   
trunk/monodevelop/main/src/addins/SourceEditor2/MonoDevelop.SourceEditor.Gui/SourceEditorBuffer.cs
   
trunk/monodevelop/main/src/addins/SourceEditor2/MonoDevelop.SourceEditor.addin.xml
Log:
* SourceEditor2/MonoDevelop.SourceEditor.Gui/SourceEditorBuffer.cs,
  MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorBuffer.cs:
  Tidy up commenting/uncommenting code, using atomic undos, and fix
  "Bug 325469 - Comment and uncomment function".
* SourceEditor2/MonoDevelop.SourceEditor.addin.xml,
  MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.addin.xml: Fix
  command IDs for comment/uncomment.

Modified: trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor/ChangeLog        
2008-02-07 00:03:01 UTC (rev 95100)
+++ trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor/ChangeLog        
2008-02-07 00:11:48 UTC (rev 95101)
@@ -1,3 +1,10 @@
+2008-02-06  Michael Hutchinson <[EMAIL PROTECTED]> 
+
+       * MonoDevelop.SourceEditor.Gui/SourceEditorBuffer.cs: Tidy up
+         commenting/uncommenting code, using atomic undos, and fix "Bug 325469 
-
+         Comment and uncomment function".
+       * MonoDevelop.SourceEditor.addin.xml: Fix command IDs for 
comment/uncomment.
+
 2008-02-05  Mike Krüger <[EMAIL PROTECTED]> 
 
        * MonoDevelop.SourceEditor.Gui/SourceEditorDisplayBinding.cs: Coneverted

Modified: 
trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorBuffer.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorBuffer.cs
       2008-02-07 00:03:01 UTC (rev 95100)
+++ 
trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.Gui/SourceEditorBuffer.cs
       2008-02-07 00:11:48 UTC (rev 95101)
@@ -745,28 +745,29 @@
                        TextIter start, end;
                        string commentTag;
                        
-                       if (!GetSelectionBounds (out start, out end))
-                               return;
+                       if (GetSelectionBounds (out start, out end)) {
+                               //selection; can contain multiple lines
+                               // Don't comment lines where no chars are 
actually selected (fixes bug #81632)
+                               if (end.LineOffset == 0)
+                                       end.BackwardLine ();
+                       }
                        
-                       commentTag = Services.Languages.GetBindingPerFileName 
(IdeApp.Workbench.ActiveDocument.FileName).CommentTag;
+                       ILanguageBinding binding = 
Services.Languages.GetBindingPerFileName 
(IdeApp.Workbench.ActiveDocument.FileName);
+                       commentTag = "//";
+                       if (binding != null && binding.CommentTag != null)
+                               commentTag = binding.CommentTag;
                        
-                       if (commentTag == null)
-                               commentTag = "//";
-                       
-                       // Don't comment lines where no chars are actually 
selected (fixes bug #81632)
-                       if (end.LineOffset == 0)
-                               end.BackwardLine ();
-                       
                        start.LineOffset = 0;
                        
                        endMark = CreateMark (null, end, false);
-                       
-                       while (start.Line <= end.Line) {
-                               curMark = CreateMark (null, start, true);
-                               Insert (ref start, commentTag);
-                               start = GetIterAtMark (curMark);
-                               end = GetIterAtMark (endMark);
-                               start.ForwardLine ();
+                       using (new AtomicUndo (this)) {
+                               while (start.Line <= end.Line) {
+                                       curMark = CreateMark (null, start, 
true);
+                                       Insert (ref start, commentTag);
+                                       start = GetIterAtMark (curMark);
+                                       end = GetIterAtMark (endMark);
+                                       start.ForwardLine ();
+                               }
                        }
                }
                
@@ -778,20 +779,12 @@
                        TextIter textStart;
                        TextIter textEnd;
                        GetSelectionBounds (out textStart, out textEnd);
-//                     if (textStart.Line == textEnd.Line)
-//                     { // all the code is in one line, just uncomment is 
text starts with comment tag
-//                             textStart.LineOffset = 0;
-//                             textEnd = textStart;
-//                             textEnd.ForwardChars (commentTag.Length);
-//                             if (textStart.GetText (textEnd) == commentTag)
-//                                     Delete (ref textStart, ref textEnd);
-//                     }
-//                     else
-                       { // uncomment the entire lines
-                               int numberOfLines = textStart.Line == 
textEnd.Line ? 1 : textEnd.Line - textStart.Line + 1;
-                               TextMark mTextStart = CreateMark (null, 
textStart, true);
-                               TextMark mTextTmp = mTextStart;
-                               
+                       
+                       int numberOfLines = textStart.Line == textEnd.Line ? 1 
: textEnd.Line - textStart.Line + 1;
+                       TextMark mTextStart = CreateMark (null, textStart, 
true);
+                       TextMark mTextTmp = mTextStart;
+                       
+                       using (new AtomicUndo (this)) {
                                for (int i=0; i<numberOfLines; i++)
                                {
                                        TextIter textTmp = GetIterAtMark 
(mTextTmp);

Modified: 
trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.addin.xml
===================================================================
--- 
trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.addin.xml
       2008-02-07 00:03:01 UTC (rev 95100)
+++ 
trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor/MonoDevelop.SourceEditor.addin.xml
       2008-02-07 00:11:48 UTC (rev 95101)
@@ -63,8 +63,7 @@
                <CommandItem id = 
"MonoDevelop.Ide.Commands.FileCommands.SaveAs" />
                <CommandItem id = 
"MonoDevelop.Ide.Commands.FileCommands.CloseFile" />
                <SeparatorItem id = "Separator1" />
-               <CommandItem id = 
"MonoDevelop.Ide.Commands.EditCommands.CommentCode" />
-               <CommandItem id = 
"MonoDevelop.Ide.Commands.EditCommands.UncommentCode" />
+               <CommandItem id = 
"MonoDevelop.Ide.Commands.EditCommands.ToggleCodeComment" />
                <CommandItem id = 
"MonoDevelop.Ide.Commands.EditCommands.IndentSelection" />
                <CommandItem id = 
"MonoDevelop.Ide.Commands.EditCommands.UnIndentSelection" />
                <ItemSet id = "Advanced" _label = "_Advanced">

Modified: trunk/monodevelop/main/src/addins/SourceEditor2/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/SourceEditor2/ChangeLog   2008-02-07 
00:03:01 UTC (rev 95100)
+++ trunk/monodevelop/main/src/addins/SourceEditor2/ChangeLog   2008-02-07 
00:11:48 UTC (rev 95101)
@@ -1,3 +1,10 @@
+2008-02-06  Michael Hutchinson <[EMAIL PROTECTED]> 
+
+       * MonoDevelop.SourceEditor.Gui/SourceEditorBuffer.cs: Tidy up
+         commenting/uncommenting code, using atomic undos, and fix "Bug 325469 
-
+         Comment and uncomment function".
+       * MonoDevelop.SourceEditor.addin.xml: Fix command IDs for 
comment/uncomment.
+
 2008-02-05  Mike Krüger <[EMAIL PROTECTED]> 
 
        * MonoDevelop.SourceEditor.Gui/SourceEditorDisplayBinding.cs: Coneverted

Modified: 
trunk/monodevelop/main/src/addins/SourceEditor2/MonoDevelop.SourceEditor.Gui/SourceEditorBuffer.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/SourceEditor2/MonoDevelop.SourceEditor.Gui/SourceEditorBuffer.cs
  2008-02-07 00:03:01 UTC (rev 95100)
+++ 
trunk/monodevelop/main/src/addins/SourceEditor2/MonoDevelop.SourceEditor.Gui/SourceEditorBuffer.cs
  2008-02-07 00:11:48 UTC (rev 95101)
@@ -746,28 +746,29 @@
                        TextIter start, end;
                        string commentTag;
                        
-                       if (!GetSelectionBounds (out start, out end))
-                               return;
+                       if (GetSelectionBounds (out start, out end)) {
+                               //selection; can contain multiple lines
+                               // Don't comment lines where no chars are 
actually selected (fixes bug #81632)
+                               if (end.LineOffset == 0)
+                                       end.BackwardLine ();
+                       }
                        
-                       commentTag = Services.Languages.GetBindingPerFileName 
(IdeApp.Workbench.ActiveDocument.FileName).CommentTag;
+                       ILanguageBinding binding = 
Services.Languages.GetBindingPerFileName 
(IdeApp.Workbench.ActiveDocument.FileName);
+                       commentTag = "//";
+                       if (binding != null && binding.CommentTag != null)
+                               commentTag = binding.CommentTag;
                        
-                       if (commentTag == null)
-                               commentTag = "//";
-                       
-                       // Don't comment lines where no chars are actually 
selected (fixes bug #81632)
-                       if (end.LineOffset == 0)
-                               end.BackwardLine ();
-                       
                        start.LineOffset = 0;
                        
                        endMark = CreateMark (null, end, false);
-                       
-                       while (start.Line <= end.Line) {
-                               curMark = CreateMark (null, start, true);
-                               Insert (ref start, commentTag);
-                               start = GetIterAtMark (curMark);
-                               end = GetIterAtMark (endMark);
-                               start.ForwardLine ();
+                       using (new AtomicUndo (this)) {
+                               while (start.Line <= end.Line) {
+                                       curMark = CreateMark (null, start, 
true);
+                                       Insert (ref start, commentTag);
+                                       start = GetIterAtMark (curMark);
+                                       end = GetIterAtMark (endMark);
+                                       start.ForwardLine ();
+                               }
                        }
                }
                
@@ -779,20 +780,12 @@
                        TextIter textStart;
                        TextIter textEnd;
                        GetSelectionBounds (out textStart, out textEnd);
-//                     if (textStart.Line == textEnd.Line)
-//                     { // all the code is in one line, just uncomment is 
text starts with comment tag
-//                             textStart.LineOffset = 0;
-//                             textEnd = textStart;
-//                             textEnd.ForwardChars (commentTag.Length);
-//                             if (textStart.GetText (textEnd) == commentTag)
-//                                     Delete (ref textStart, ref textEnd);
-//                     }
-//                     else
-                       { // uncomment the entire lines
-                               int numberOfLines = textStart.Line == 
textEnd.Line ? 1 : textEnd.Line - textStart.Line + 1;
-                               TextMark mTextStart = CreateMark (null, 
textStart, true);
-                               TextMark mTextTmp = mTextStart;
-                               
+                       
+                       int numberOfLines = textStart.Line == textEnd.Line ? 1 
: textEnd.Line - textStart.Line + 1;
+                       TextMark mTextStart = CreateMark (null, textStart, 
true);
+                       TextMark mTextTmp = mTextStart;
+                       
+                       using (new AtomicUndo (this)) {
                                for (int i=0; i<numberOfLines; i++)
                                {
                                        TextIter textTmp = GetIterAtMark 
(mTextTmp);

Modified: 
trunk/monodevelop/main/src/addins/SourceEditor2/MonoDevelop.SourceEditor.addin.xml
===================================================================
--- 
trunk/monodevelop/main/src/addins/SourceEditor2/MonoDevelop.SourceEditor.addin.xml
  2008-02-07 00:03:01 UTC (rev 95100)
+++ 
trunk/monodevelop/main/src/addins/SourceEditor2/MonoDevelop.SourceEditor.addin.xml
  2008-02-07 00:11:48 UTC (rev 95101)
@@ -57,8 +57,7 @@
                <CommandItem id = 
"MonoDevelop.Ide.Commands.FileCommands.SaveAs" />
                <CommandItem id = 
"MonoDevelop.Ide.Commands.FileCommands.CloseFile" />
                <SeparatorItem id = "Separator1" />
-               <CommandItem id = 
"MonoDevelop.Ide.Commands.EditCommands.CommentCode" />
-               <CommandItem id = 
"MonoDevelop.Ide.Commands.EditCommands.UncommentCode" />
+               <CommandItem id = 
"MonoDevelop.Ide.Commands.EditCommands.ToggleCodeComment" />
                <CommandItem id = 
"MonoDevelop.Ide.Commands.EditCommands.IndentSelection" />
                <CommandItem id = 
"MonoDevelop.Ide.Commands.EditCommands.UnIndentSelection" />
                <ItemSet id = "Advanced" _label = "_Advanced">

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

Reply via email to