Skip to content

Commit 603e87c

Browse files
authored
Fix pasting a single line without selection
1 parent 788a76e commit 603e87c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/pasteEventHandler.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class PasteEditProvider implements DocumentPasteEditProvider {
5555
this.languageClient = languageClient;
5656
}
5757

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

77+
const editorData = dataTransfer.get("vscode-editor-data")?.value;
78+
const isSingleLineCopy = Boolean(editorData && JSON.parse(editorData).isFromEmptySelection);
79+
const isFromSameDocument = this.copiedContent === insertText && this.copiedDocumentUri === document.uri.toString();
80+
if (isSingleLineCopy && isFromSameDocument) {
81+
return undefined; // Let VS Code handle this normally
82+
}
83+
7684
const range = ranges[0];
7785

7886
const location: Location = {

0 commit comments

Comments
 (0)