Spent days and nights on selection problems in the CSS source editor. Finally won the battle implementing this.