Skip to content

Commit 5830db6

Browse files
authored
Fix that pasting no longer goes through the type command on Firefox (microsoft#255912)
Fix that pasting goes through the `type` command on Firefox When pasting on Firefox, I have observed that there is no `paste` event, but only an `input` event. I don't know why this would happen, but I found that the `inputType` property on `input` events can be used to determine insertions caused by pasting.
1 parent e9df78f commit 5830db6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/vs/editor/browser/controller/editContext/textArea/textAreaEditContextInput.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,15 @@ export class TextAreaInput extends Disposable {
342342
|| typeInput.replaceNextCharCnt !== 0
343343
|| typeInput.positionDelta !== 0
344344
) {
345-
this._onType.fire(typeInput);
345+
// https://w3c.github.io/input-events/#interface-InputEvent-Attributes
346+
if (e.inputType === 'insertFromPaste') {
347+
this._onPaste.fire({
348+
text: typeInput.text,
349+
metadata: InMemoryClipboardMetadataManager.INSTANCE.get(typeInput.text)
350+
});
351+
} else {
352+
this._onType.fire(typeInput);
353+
}
346354
}
347355
}));
348356

0 commit comments

Comments
 (0)