fix #968 by check the nullity of text range