avoid NPE for non-text editors

(cherry picked from commit d00138cdaebd4f2c634c10c772d8b9ca16287e0c)