Skip to content

Commit da20b1a

Browse files
authored
Refactor paste handling for single line copies
1 parent fe5dcae commit da20b1a

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/pasteEventHandler.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,13 @@ class PasteEditProvider implements DocumentPasteEditProvider {
7474
return null;
7575
}
7676

77-
// Skip paste handling for single line copies from the same document to avoid unwanted escaping
78-
// in string literals when copying lines
79-
const isSingleLineCopy = !insertText.includes('\n') && !insertText.includes('\r');
77+
const editorData = dataTransfer.get("vscode-editor-data")?.value;
78+
const isSingleLineCopy = Boolean(editorData && JSON.parse(editorData).isFromEmptySelection);
8079
const isFromSameDocument = this.copiedContent === insertText && this.copiedDocumentUri === document.uri.toString();
8180
if (isSingleLineCopy && isFromSameDocument) {
8281
return undefined; // Let VS Code handle this normally
8382
}
8483

85-
// Skip paste handling when pasting content that contains quotes to avoid unwanted escaping
86-
// This is a broader check than the above to handle cases where content is modified or from different documents
87-
if (insertText.includes('"')) {
88-
return undefined; // Let VS Code handle this normally
89-
}
90-
9184
const range = ranges[0];
9285

9386
const location: Location = {

0 commit comments

Comments
 (0)