Project: JDT
Bug 78450 [Performance] PasteAction is making selection slow
Reported: 2004-11-11 17:37:02 | Status: resolved fixed

The method PasteAction.canOperateOn is invoked on every selection change. This is not required and is extremely slow on many platforms. The PasteAction is checking that there is something on the clipboard that can be pasted on every single selection change event. This is an expensive operation and is entirely unneccessary. The check should be done when the user invokes Ctrl+V or when the user opens the context menu. In addition to being slow, it is not correct. Another application could change the contents of the clipboard invalidating the check performed on selection change. I am not quite sure why the selection has anything to do with pasting other than the fact that on paste, the selection will be replaced. At one time when there was a Paste toolitem in the toolbar, back then it was neccessary to poll the clipboard to toggle the enabling of the toolitem but I do not understand why that was tied to selection. I can change the contents of the clipboard to not contain any valid data using another application and the Paste menu item is still enabled in the context menu of the java editor.

Files changed in fix:
org.eclipse.jdt.ui/ui refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/PasteAction.java