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.
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