Skip to content

Commit

Permalink
! Removed slashes between lines when joining lines in C#, C/C++, Java…
Browse files Browse the repository at this point in the history
…/JavaScript files
  • Loading branch information
wmjordan committed Mar 27, 2021
1 parent dd07833 commit 293d1e7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Codist/Helpers/TextEditorHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ public static void JoinSelectedLines(this ITextView view) {
var b = new ReusableResourceHolder<System.Text.StringBuilder>();
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':
Expand All @@ -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;
Expand Down Expand Up @@ -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

Expand All @@ -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;
Expand Down

0 comments on commit 293d1e7

Please sign in to comment.