Is there a way to listen to the paste event?

Viewed 175
1 Answers

It seems like it would be possible to detect pastes with fairly high confidence by:

  1. Subscribing to workspace.onDidChangeTextDocument(workspace api) to get all text edits
  2. On edit, check env.clipboard.readText() to get the current content of the clipboard
  3. From the TextDocumentChangeEvent, check each contentChanges entry's text and see if it matches the clipboard text
  4. If it matches (and it isn't a trivial edit like a single character), they probably just pasted.
Related