Open
Description
Imagine the following file:
// comment
function f() {}
When I press Ctrl+x on the line containing f
, and paste it again, what VS Code does is it creates a buffer with the following contents:
// comment
and then sends **this request for paste edits**
{
"file": "d:\\scratch\\copypasta\\src\\file.ts",
"pastedText": [
"function f() {}\r\n"
],
"pasteLocations": [
{
"start": {
"line": 2,
"offset": 1
},
"end": {
"line": 2,
"offset": 1
}
}
],
"copiedFrom": {
"file": "d:\\scratch\\copypasta\\src\\file.ts",
"spans": [
{
"start": {
"line": 3,
"offset": 1
},
"end": {
"line": 3,
"offset": 16
}
}
]
}
}
and receives **this response**.
{
"edits": [
{
"fileName": "d:/scratch/copypasta/src/file.ts",
"textChanges": [
{
"start": {
"line": 1,
"offset": 15
},
"end": {
"line": 1,
"offset": 15
},
"newText": "function f() {}\r\n"
}
]
}
],
"fixId": "providePostPasteEdits"
}
After the paste, the file no longer contains the original contents, and instead contains invalid text.
// commentfunction f() {}