Support smart escaping of text when pasting into string expressions (part2).#61111
Support smart escaping of text when pasting into string expressions (part2).#61111CyrusNajmabadi merged 87 commits intodotnet:mainfrom
Conversation
|
@davidwengier This is has been substantially rewritten now based on your suggestion. The general approach now is that when the cut/copy command goes through we capture the 'processed' information we need about the string literal the user copied from. Then, when a paste occurs, we use that information directly instead of trying to back infer what the text changes would have meant in the original document. |
|
|
||
| using static StringCopyPasteHelpers; | ||
|
|
||
| internal readonly struct StringInfo |
There was a problem hiding this comment.
this is information we were computing before, but storing as separate fields. i aggregated into into a single type to keep things cleaner.
| @"var x = $"""""""" | ||
| """""" | ||
| ""[||]""""""", | ||
| [||]""""""""", |
There was a problem hiding this comment.
this is an improvement over the prior behavior. the caret now stays before the delimiters instead of moving partway into the closing delimiters.
|
How does one -disable- this feature. It's been a usability nightmare for me. Sure, the feature is "cool", but it's not always wanted(in my case, -very- infrequently desired). Changes to basic functions absolutely require options to be able to enable or disable. I can't find anything in VS17.3.6 options for preventing the behavior where on every ctrl+v I have to do a ctrl+z to get what I intended to paste. Please add a "Smart escape characters on paste” option so pasting behavior can revert back for those of us that need it. Also introduce “Edit->Paste Special->Smart escape paste” for those of us that do disable the feature for ctrl+v, but have opportunities where it would be beneficial. |
Yay! Exactly what I needed. Thank you. That brings up a different issue then. That option doesn't appear in "Search Options" I typed in "paste"(I tried several different searches looking for an option to disable). It is because it's experimental? |
|
Not sure. @davidwengier i think you added some sort of searching support to |
|
I made the search term highlight on the page, if the page shows up in the search results, but sadly the act of showing up in the search results is 20 year old technology. The search matches on any word in this resource string which needs to be manually updated when a new option is added. |

Followup to #60036. This adds support for understanding copy/paste from an existing string literal.
Initial support for a smart-string-copy-paste system. The general ideas here are:
""from inside a verbatim string (like@" goo "" bar "" baz "), then we can know this represents a single quote character.For all of the above, we ensure that any special work we do happens as a second edit transaction. THat way if the user ever doesn't want the contextual-pasting result, they can undo and get back to exactly the code that pastes normally.
This PR effectively adds the italicized item in this table: