Fixes #1592 - Search error when code mirror is on

Fixes #1592  - Search error when code mirror is on