Skip to content

fix: Prevent code suggestions on paste

Enrique Alcántara requested to merge 1058-prevent-code-suggestions-on-paste into main

Description

It rejects code completion requests when the user pastes a code block.

Implementation details

The VSCode Extension API doesn't provide a paste event listener. This MR circumvents this limitation by listening to the DocumentChanged event and comparing the event's content with the clipboard's content. Code completion requests are rejected if the data points match and the event happens within a time interval.

Related Issues

Resolves 1058

How has this been tested?

  1. Check out the branch.
  2. Paste text on a JavaScript file.
  3. Code suggestions should not appear after pasting text

Screenshots (if appropriate):

Before After
prevent_code_suggestions_before.mov prevent_code_suggestions_on_paste_after.mov

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation
  • Chore (Related to CI or Packaging to platforms)
  • Test gap

Related to #1058 (closed)

Edited by Enrique Alcántara

Merge request reports