fix #968 by check the nullity of text range
Merge pull request #1088 from chrox/fix_968

fix #968 by check the nullity of text range