Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/pasteEventHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class PasteEditProvider implements DocumentPasteEditProvider {
this.languageClient = languageClient;
}


async prepareDocumentPaste?(document: TextDocument, _ranges: readonly Range[], dataTransfer: DataTransfer, _token: CancellationToken): Promise<void> {
const copiedContent: string = await dataTransfer.get(TEXT_MIMETYPE).asString();
if (copiedContent) {
Expand All @@ -73,6 +74,20 @@ class PasteEditProvider implements DocumentPasteEditProvider {
return null;
}

// Skip paste handling for single line copies from the same document to avoid unwanted escaping
// in string literals when copying lines
const isSingleLineCopy = !insertText.includes('\n') && !insertText.includes('\r');
Copy link
Collaborator

@fbricon fbricon Jan 13, 2026

Choose a reason for hiding this comment

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

change to

const editorData = dataTransfer.get("vscode-editor-data")?.value;
const isSingleLineCopy = Boolean(editorData && JSON.parse(editorData).isFromEmptySelection);

const isFromSameDocument = this.copiedContent === insertText && this.copiedDocumentUri === document.uri.toString();
if (isSingleLineCopy && isFromSameDocument) {
return undefined; // Let VS Code handle this normally
}

// Skip paste handling when pasting content that contains quotes to avoid unwanted escaping
// This is a broader check than the above to handle cases where content is modified or from different documents
if (insertText.includes('"')) {
return undefined; // Let VS Code handle this normally
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You need to remove this whole block, as it simply breaks the smart pasting feature


const range = ranges[0];

const location: Location = {
Expand Down