Skip to content

Do not try to do a smart copy/paste when the paste change is not fully within the string.#61317

Merged
CyrusNajmabadi merged 7 commits into
dotnet:mainfrom
CyrusNajmabadi:smartCopyPasteLineCopy
May 16, 2022
Merged

Do not try to do a smart copy/paste when the paste change is not fully within the string.#61317
CyrusNajmabadi merged 7 commits into
dotnet:mainfrom
CyrusNajmabadi:smartCopyPasteLineCopy

Conversation

@CyrusNajmabadi

@CyrusNajmabadi CyrusNajmabadi commented May 13, 2022

Copy link
Copy Markdown
Contributor

Fixes #61316.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 13, 2022 23:23
@CyrusNajmabadi CyrusNajmabadi requested a review from a team May 13, 2022 23:23
@ghost ghost added the Area-IDE label May 13, 2022
@CyrusNajmabadi CyrusNajmabadi requested a review from sharwell May 13, 2022 23:23
Comment thread src/EditorFeatures/CSharp/StringCopyPaste/StringCopyPasteCommandHandler.cs Outdated
var stringExpressionBeforePasteFromChanges = TryGetCompatibleContainingStringExpression(
documentBeforePaste, new NormalizedSnapshotSpanCollection(snapshotBeforePaste, snapshotBeforePaste.Version.Changes.Select(c => c.OldSpan)), cancellationToken);
if (stringExpressionBeforePaste != stringExpressionBeforePasteFromChanges)
return;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is an additional sanity check which also fixes the issue. I would like both though as we both dont' want to do anything 'smart' if the editor decides to make the edits outside the string and we don't want to do anything smart (for now) with line-copy-paste as it likely needs some though to make sense of what it means with string literals.

Comment thread src/EditorFeatures/CSharp/StringCopyPaste/StringCopyPasteCommandHandler.cs Outdated
@CyrusNajmabadi CyrusNajmabadi requested a review from sharwell May 14, 2022 02:44
@CyrusNajmabadi CyrusNajmabadi changed the title Disable smart copy/paste when line-copy is involved. Do not try to do a smart copy/paste when the paste change is not fully within the string. May 14, 2022

@sharwell sharwell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 It would be better to truly support line-copy and line-paste by expanding $$ to the containing line (e.g. to copy a line from inside a @"" string and paste it inside $$""" string), but this is still better than what it does today.

@CyrusNajmabadi CyrusNajmabadi merged commit 557a497 into dotnet:main May 16, 2022
@CyrusNajmabadi CyrusNajmabadi deleted the smartCopyPasteLineCopy branch May 16, 2022 16:40
@ghost ghost added this to the Next milestone May 16, 2022
@Cosifne Cosifne modified the milestones: Next, 17.3 P2 May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Smart string escape on paste broken with line copy/paste

3 participants