final StyledText widget = editor.getViewer().getTextWidget();
if (registeredWidgets.contains(widget)) {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
widget.removeListener(SWT.KeyDown, listener);
widget.removeListener(SWT.MouseDown, listener);
}
});
registeredWidgets.remove(widget);
}