8000 Newlines removed/incorrect code generated for `getPasteEdits` · Issue #58784 · microsoft/TypeScript · GitHub
[go: up one dir, main page]

Skip to content
Newlines removed/incorrect code generated for getPasteEdits #58784
Open
@DanielRosenwasser

Description

@DanielRosenwasser

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() {}

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0