[svn] r7782: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs

kliss svnadmin at nemerle.org
Tue Sep 4 18:19:20 CEST 2007


Log:
Fix bug #1050 (comment/incomment block)

Author: kliss
Date: Tue Sep  4 18:19:08 2007
New Revision: 7782

Modified:
   vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs

Modified: vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs
==============================================================================
--- vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs	(original)
+++ vs-plugin/trunk/Nemerle.VsIntegration/LanguageService/NemerleViewFilter.cs	Tue Sep  4 18:19:08 2007
@@ -287,6 +287,30 @@
 		int _startLine;
 		int _startPos;
 
+        public override void CommentSelection()
+        {
+            TextSpan ts = GetRealSelectionSpan();
+            Source.CommentLines(ts, "//");
+        }
+        public override void UncommentSelection()
+        {
+            TextSpan ts = GetRealSelectionSpan();
+            Source.UncommentLines(ts, "//");
+        }
+
+	    private TextSpan GetRealSelectionSpan()
+	    {
+            // workaround for bug #1050
+            // TextView.GetSelection adds caret position to the selection span,
+            // so when we select whole block of text (caret is at the first column),
+            // one extra line is added to the selection (where the caret is left)
+            TextSpan ts = new TextSpan();
+	        TextView.GetSelection(out ts.iStartLine, out ts.iStartIndex, out ts.iEndLine, out ts.iEndIndex);
+	        if (ts.iEndIndex == 0)
+	            ts.iEndLine--;
+	        return ts;
+	    }
+
 		public override bool HandlePreExec(
 			ref Guid guidCmdGroup, uint nCmdId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
 		{
@@ -315,6 +339,9 @@
 							return true; // Handled the command.
 						}
 
+                    case VsCommands2K.COMMENT_BLOCK:
+                        CommentSelection();
+                        return true;
 					case VsCommands2K.SURROUNDWITH:
 						{
 							ExpansionProvider ep = GetExpansionProvider();
@@ -367,6 +394,15 @@
 		public override void HandlePostExec(
 			ref Guid guidCmdGroup, uint nCmdId, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut, bool bufferWasChanged)
 		{
+            // Special handling of "Toggle all outlining" command
+            if (guidCmdGroup == typeof(VsCommands2K).GUID)
+            {
+                if ((VsCommands2K)nCmdId == VsCommands2K.OUTLN_TOGGLE_ALL)
+                {
+                    Source.CollapseAllRegions();
+                    return;
+                }
+            }
 			base.HandlePostExec(ref guidCmdGroup, nCmdId, nCmdexecopt, pvaIn, pvaOut, bufferWasChanged);
 
 			if (_startLine >= 0 && Source.MethodData.IsDisplayed)



More information about the svn mailing list