Author: mkrueger
Date: 2008-02-19 09:23:41 -0500 (Tue, 19 Feb 2008)
New Revision: 96148

Modified:
   trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/ChangeLog
   
trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
Log:
* MonoDevelop.SourceEditor/SourceEditorView.cs: Fixed comment/uncomment
  code.

Modified: trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/ChangeLog
===================================================================
--- trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/ChangeLog       
2008-02-19 14:11:54 UTC (rev 96147)
+++ trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/ChangeLog       
2008-02-19 14:23:41 UTC (rev 96148)
@@ -1,5 +1,10 @@
 2008-02-19  Mike Krüger <[EMAIL PROTECTED]> 
 
+       * MonoDevelop.SourceEditor/SourceEditorView.cs: Fixed comment/uncomment
+         code.
+
+2008-02-19  Mike Krüger <[EMAIL PROTECTED]> 
+
        * MonoDevelop.SourceEditor/SourceEditorWidget.cs,
          MonoDevelop.SourceEditor/SourceEditorView.cs: Fixed Bug 362889 - Error
          underlining not properly redrawn.

Modified: 
trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
===================================================================
--- 
trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
    2008-02-19 14:11:54 UTC (rev 96147)
+++ 
trunk/monodevelop/main/src/addins/MonoDevelop.SourceEditor2/MonoDevelop.SourceEditor/SourceEditorView.cs
    2008-02-19 14:23:41 UTC (rev 96148)
@@ -760,23 +760,30 @@
                        if (endLineNr < 0)
                                endLineNr = Document.LineCount;
                        
+                       LineSegment anchorLine   = 
TextEditor.IsSomethingSelected ? TextEditor.Document.GetLineByOffset 
(TextEditor.SelectionAnchor) : null;
+                       int         anchorColumn = 
TextEditor.IsSomethingSelected ? TextEditor.SelectionAnchor - anchorLine.Offset 
: -1;
+                       
                        StringBuilder commentTag = new 
StringBuilder(Services.Languages.GetBindingPerFileName 
(this.ContentName).CommentTag ?? "//");
                        Document.BeginAtomicUndo ();
                        foreach (LineSegment line in TextEditor.SelectedLines) {
                                Document.Insert (line.Offset, commentTag);
                        }
                        if (TextEditor.IsSomethingSelected) {
-                               TextEditor.SelectionAnchor += commentTag.Length;
+                               if (TextEditor.SelectionAnchor < 
TextEditor.Caret.Offset) {
+                                       TextEditor.SelectionAnchor = 
System.Math.Min (anchorLine.Offset + anchorLine.EditableLength, System.Math.Max 
(anchorLine.Offset, TextEditor.SelectionAnchor + commentTag.Length));
+                               } else {
+                                       TextEditor.SelectionAnchor = 
System.Math.Min (anchorLine.Offset + anchorLine.EditableLength, System.Math.Max 
(anchorLine.Offset, anchorLine.Offset + anchorColumn + commentTag.Length));
+                               }
                        }
                        
-                       DocumentLocation selectionEnd = 
TextEditor.IsSomethingSelected ? TextEditor.Document.OffsetToLocation 
(TextEditor.SelectionRange.EndOffset) : DocumentLocation.Empty;
-                       if (selectionEnd.Column != 0) {
+                       if (TextEditor.Caret.Column != 0) {
                                TextEditor.Caret.PreserveSelection = true;
                                TextEditor.Caret.Column += commentTag.Length;
-                               if (TextEditor.IsSomethingSelected) 
-                                       TextEditor.ExtendSelectionTo 
(TextEditor.Caret.Offset);
                                TextEditor.Caret.PreserveSelection = false;
                        }
+                       
+                       if (TextEditor.IsSomethingSelected) 
+                               TextEditor.ExtendSelectionTo 
(TextEditor.Caret.Offset);
                        Document.EndAtomicUndo ();
                        Document.CommitMultipleLineUpdate (startLineNr, 
endLineNr);
                }
@@ -787,6 +794,9 @@
                        int endLineNr   = TextEditor.IsSomethingSelected ? 
Document.OffsetToLineNumber (TextEditor.SelectionRange.EndOffset) : 
TextEditor.Caret.Line;
                        if (endLineNr < 0)
                                endLineNr = Document.LineCount;
+                       LineSegment anchorLine   = 
TextEditor.IsSomethingSelected ? TextEditor.Document.GetLineByOffset 
(TextEditor.SelectionAnchor) : null;
+                       int         anchorColumn = 
TextEditor.IsSomethingSelected ? TextEditor.SelectionAnchor - anchorLine.Offset 
: -1;
+                       
                        string commentTag = 
Services.Languages.GetBindingPerFileName (this.ContentName).CommentTag ?? "//";
                        Document.BeginAtomicUndo ();
                        int first = -1;
@@ -803,17 +813,24 @@
                                if (first < 0)
                                        first = last;
                        }
-//                     if (TextEditor.IsSomethingSelected) 
-//                             TextEditor.GetTextEditorData 
().SelectionStart.Column = System.Math.Max (0, TextEditor.GetTextEditorData 
().SelectionStart.Column - first);
                        
-                       DocumentLocation selectionEnd = 
TextEditor.IsSomethingSelected ? TextEditor.Document.OffsetToLocation 
(TextEditor.SelectionRange.EndOffset) : DocumentLocation.Empty;
-                       if (selectionEnd.Column != 0) {
+                       if (TextEditor.IsSomethingSelected) {
+                               if (TextEditor.SelectionAnchor < 
TextEditor.Caret.Offset) {
+                                       TextEditor.SelectionAnchor = 
System.Math.Min (anchorLine.Offset + anchorLine.EditableLength, System.Math.Max 
(anchorLine.Offset, TextEditor.SelectionAnchor - first));
+                               } else {
+                                       TextEditor.SelectionAnchor = 
System.Math.Min (anchorLine.Offset + anchorLine.EditableLength, System.Math.Max 
(anchorLine.Offset, anchorLine.Offset + anchorColumn - last));
+                               }
+                       }
+                       
+                       if (TextEditor.Caret.Column != 0) {
                                TextEditor.Caret.PreserveSelection = true;
                                TextEditor.Caret.Column = System.Math.Max (0, 
TextEditor.Caret.Column - last);
-                               if (TextEditor.IsSomethingSelected) 
-                                       TextEditor.ExtendSelectionTo 
(TextEditor.Caret.Offset);
                                TextEditor.Caret.PreserveSelection = false;
                        }
+                       
+                       if (TextEditor.IsSomethingSelected) 
+                               TextEditor.ExtendSelectionTo 
(TextEditor.Caret.Offset);
+               
                        Document.EndAtomicUndo ();
                        Document.CommitMultipleLineUpdate (startLineNr, 
endLineNr);
                }

_______________________________________________
Mono-patches maillist  -  Mono-patches@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to