Skip to content

Ctrl+V to paste sometimes deletes text #146541

Closed
@sjc-gh

Description

@sjc-gh

Pasting copied text over selected target text actually deletes the text instead. This only seems to happen if the line containing the selected target text is using Typescript string interpolation.

For example, suppose I have the following function in a .ts file:

  function reportBug(): void {
    console.log(`${Date.now()} [MyClass.someFunction] - Some source text to copy.`);
    console.log(`${Date.now()} [MyClass.someFunction] - Some destination for copied text.`);
  }

If I select and copy the text "Some source text to copy.", select the text "Some destination for copied text.", then hit Ctrl+V to paste, I expect:

  function reportBug(): void {
    console.log(`${Date.now()} [MyClass.someFunction] - Some source text to copy.`);
    console.log(`${Date.now()} [MyClass.someFunction] - Some source text to copy.`);
  }

But instead I get:

  function reportBug(): void {
    console.log(`${Date.now()} [MyClass.someFunction] - Some source text to copy.`);
    console.log(`${Date.now());
  }

If I hit hit Ctrl+Z after the paste, it seems to undo some deletion and show what I pasted.

If however my original function did not include the interpolation placeholder:

  function reportBug(): void {
    console.log(`[MyClass.someFunction] - Some source text to copy.`);
    console.log(`[MyClass.someFunction] - Some destination for copied text.`);
  }

Then the paste works as expected.

VS Code info:

Version: 1.65.2 (system setup)
Commit: c722ca6
Date: 2022-03-10T14:33:55.248Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19042

- Steve

Metadata

Metadata

Assignees

Labels

*duplicateIssue identified as a duplicate of another issue(s)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions