Make vertical moves with large counts move to the first or last line. #44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While working on my last PR I noticed that sometimes we would get an error if we tried to make a large vertical move, when the count was large enough to send the lines "out of bounds".
When moving a lines, if it was only slightly out of bounds (1 too much) then it would move the line to the end of the file. The main situation where this happens is if we move the last line down by one -- it stays in the same place without giving an error. It also did not give an error if you tried to move the penultimate line down by two -- it would move it down by one, so it became the last line in the file. However, if you try to move the last line down by 2+ or the penultimate line by 3+ it would give an error E16: Invalid Range.
Moving blocks vertically had a similar problem. If the block was at the end of the file and we tried to move down by one it would also do nothing. But if we tried do move the penultimate line by 2 or by 3+ it would not move it at all.
This commit updates the behavior to be more consistent. Large vertical moves now move the line/block to the first or last line of the file, without throwing any errors.