meraymond2 / idris-vscode

Idris front-end for VS Code
MIT License
58 stars 10 forks source link

Handle insert past doc end #47

Closed meraymond2 closed 3 years ago

meraymond2 commented 3 years ago

If you are on the final line of the document and attempt to execute a command that inserts a new line VS would throw an error. It's trying to check whether the next line is indented and fails because that line doesn't exist. To fix that, I'm checking first whether it's the final line.

VS will not error if you try to insert past the end of the document, but it will just append it to the final position, so it will end up on the same line. To get around this, I conditionally start the new content with a newline, again just by checking if it's the final line.

This issue only arises if VS isn't set to insert a final newline on save, otherwise it would save before the command, insert a newline, and then insert there.

Should fix the second half of https://github.com/meraymond2/idris-vscode/issues/45