Improve and fix selection event handling in IdeCodeListener