-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for smart string/copy paste when the destination is a raw string literal. #61177
Conversation
} | ||
|
||
return ImmutableArray.Create(new TextChange(_selectionBeforePaste.Span.ToTextSpan(), builder.ToString())); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method called out to two methods that were almost identical in how they behaved. so i merged those two methods into one, and then tweaked it in the one place they differ in behavior.
// At this point, we will now have the information necessary to actually insert the content and do things | ||
// like give interpolations the proper number of braces for the final string we're making. | ||
|
||
var dummyContentEdit = GetContentEditForRawString(insertInterpolations: false, dollarSignCount: -1, indentationWhitespace: ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method is very long, but is described by the above comment. i intend to break it apart into pieces to make it clearer as to what happens.
} | ||
} | ||
|
||
private TextChange GetContentEditForRawString( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore the diff in this mehtod. it comes from the fact that i merged two similar methods into one (talked above above), but then added a method for the raw case. the diff thinkgs the raw-method shoudl diff against one of the prior methods.
src/EditorFeatures/CSharp/StringCopyPaste/KnownSourcePasteProcessor.cs
Outdated
Show resolved
Hide resolved
@davidwengier let me know what you think, and if there are ways to make things clearer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic makes sense, though one thing that isn't clear (and I haven't looked through the tests) but is there coverage for the scenario where the newly pasted interpolations need to have braces added? eg, if pasting from a $"""
to a $$$"""
or something.
Though I imagine this stuff gets extremely complicated so its probably fair enough if some things just aren't supported.
Yup. Test for that and tests for ensuring that if we need to change the number of '$' that we also update existing interpolations. |
This includes properly fixing up the delimiters (adding
$
and"
as necessayr) as well as handling indentation and also escaping internal braces on interpolations as necessary.Lots of tests added. Several hundred more to go there.