diff --git a/Codist/Helpers/TextEditorHelper.cs b/Codist/Helpers/TextEditorHelper.cs index 3cbe1b65..2bfaac18 100644 --- a/Codist/Helpers/TextEditorHelper.cs +++ b/Codist/Helpers/TextEditorHelper.cs @@ -496,7 +496,7 @@ public static void JoinSelectedLines(this ITextView view) { var b = new ReusableResourceHolder(); var sb = b.Resource; var p = 0; - bool nl = false; + bool nl = false, noSlash = NoSlash(view); for (int i = 0; i < t.Length; i++) { switch (t[i]) { case '\r': @@ -511,6 +511,11 @@ public static void JoinSelectedLines(this ITextView view) { case ' ': case '\t': continue; + case '/': + if (nl && noSlash && (t[j-1] == '/' || j+1 < t.Length && t[j+1] == '/')) { + continue; + } + goto default; case '\n': case '\r': nl = true; @@ -554,6 +559,10 @@ public static void JoinSelectedLines(this ITextView view) { bool NeedSpace(string tokens, char c) { return tokens.IndexOf(c) == -1 && c < 0x2E80; } + bool NoSlash(ITextView v) { + var ct = v.TextBuffer.ContentType; + return ct.IsOfType(Constants.CodeTypes.CSharp) || ct.IsOfType(Constants.CodeTypes.CPlusPlus) || ct.LikeContentType("TypeScript") || ct.LikeContentType("Java"); + } } #endregion @@ -566,6 +575,9 @@ public static ITextDocument GetTextDocument(this ITextBuffer textBuffer) { public static bool LikeContentType(this ITextBuffer textBuffer, string typeName) { return textBuffer.ContentType.TypeName.IndexOf(typeName) != -1; } + public static bool LikeContentType(this IContentType contentType, string typeName) { + return contentType.TypeName.IndexOf(typeName) != -1; + } public static IWpfTextView GetMouseOverDocumentView() { return _MouseOverTextView;