Example #1
0
        public void MinusGitHub()
        {
            string raw = "-        private const string _regex = @\"^([\\d]+|\\+|\\-)(\\s|\\.)?\";\r\n-        private const string _regex = @\"^([\\d]+|\\+|\\-)(\\s|\\.)?\";\r\n-        private const string _regex = @\"^([\\d]+|\\+|\\-)(\\s|\\.)?\";\r\n";
              string expected = "       private const string _regex = @\"^([\\d]+|\\+|\\-)(\\s|\\.)?\";\r\n       private const string _regex = @\"^([\\d]+|\\+|\\-)(\\s|\\.)?\";\r\n       private const string _regex = @\"^([\\d]+|\\+|\\-)(\\s|\\.)?\";";

              _cleaner = new PasteCleaner(raw);
              _cleaner.IsDirty();

              string actual = _cleaner.Clean();
              Assert.AreEqual(expected, actual);
        }
Example #2
0
        public void LineNumberFirefox()
        {
            string raw = "1\t<PropertyGroup>\r\n2\t  <DeployOnBuild Condition=\" '$(DeployProjA)'!='' \">$(DeployProjA)</DeployOnBuild>\r\n3\t</PropertyGroup>";
            string expected = "<PropertyGroup>\r\n  <DeployOnBuild Condition=\" '$(DeployProjA)'!='' \">$(DeployProjA)</DeployOnBuild>\r\n</PropertyGroup>";

            _cleaner = new PasteCleaner(raw);
            _cleaner.IsDirty();

            string actual = _cleaner.Clean();
            Assert.AreEqual(expected, actual);
        }
Example #3
0
        public void CleanEmptyLines()
        {
            string raw = "public static string RemoveWhiteSpaceFromStylesheets(string body)\r\n\r\n{\r\n\r\n  body = Regex.Replace(body, @\"[a-zA-Z]+#\", \"#\");\r\n\r\n  body = Regex.Replace(body, @\"[\\n\\r]+\\s*\", string.Empty);\r\n\r\n  body = Regex.Replace(body, @\"\\s+\", \" \");\r\n\r\n  body = Regex.Replace(body, @\"\\s?([:,;{}])\\s?\", \"$1\");\r\n\r\n  body = body.Replace(\";}\", \"}\");\r\n\r\n  body = Regex.Replace(body, @\"([\\s:]0)(px|pt|%|em)\", \"$1\");\r\n\r\n \r\n\r\n  // Remove comments from CSS\r\n\r\n  body = Regex.Replace(body, @\"/\\*[\\d\\D]*?\\*/\", string.Empty);\r\n\r\n \r\n\r\n  return body;\r\n\r\n}\r\n";
            string expected = "public static string RemoveWhiteSpaceFromStylesheets(string body)\r\n{\r\n  body = Regex.Replace(body, @\"[a-zA-Z]+#\", \"#\");\r\n  body = Regex.Replace(body, @\"[\\n\\r]+\\s*\", string.Empty);\r\n  body = Regex.Replace(body, @\"\\s+\", \" \");\r\n  body = Regex.Replace(body, @\"\\s?([:,;{}])\\s?\", \"$1\");\r\n  body = body.Replace(\";}\", \"}\");\r\n  body = Regex.Replace(body, @\"([\\s:]0)(px|pt|%|em)\", \"$1\");\r\n \r\n  // Remove comments from CSS\r\n  body = Regex.Replace(body, @\"/\\*[\\d\\D]*?\\*/\", string.Empty);\r\n \r\n  return body;\r\n}";

            _cleaner = new PasteCleaner(raw);
            _cleaner.IsDirty();

            string actual = _cleaner.Clean();

            Assert.AreEqual(expected, actual);
        }
        private void ReplaceText(PasteCleaner cleaner, TextDocument doc, EditPoint start, string text)
        {
            string clean = cleaner.Clean();

            _dte.UndoContext.Open("Paste FixR");

            // Insert
            start.ReplaceText(text.Replace("\n", string.Empty).Length, clean, 0);
            //start.Insert(clean);

            // Format
            doc.Selection.MoveToPoint(start, true);
            FormatSelection();
            _textView.Selection.Clear();

            _dte.UndoContext.Close();
        }
        private void ReplaceText(PasteCleaner cleaner, TextDocument doc, EditPoint start, string text)
        {
            string clean = cleaner.Clean();
            _dte.UndoContext.Open("Paste FixR");

            // Insert
            start.ReplaceText(text.Replace("\n", string.Empty).Length, clean, 0);
            //start.Insert(clean);

            // Format
            doc.Selection.MoveToPoint(start, true);
            FormatSelection();
            _textView.Selection.Clear();

            _dte.UndoContext.Close();
        }