Fix position ranges in "refactor"

Fix ensime/ensime-server#332. Also fix DOS-mode shenanignans.