Fix cursor position after calling an each-based command, when possible
requested to merge pablorackham/ktexteditor:work/pablo/fix-each-commands-cursor-position into master
Hello :),
This is a small fix that attempt to get the cursor bask where it was after executing a command.
It works by checking if the number of lines hasn't changed and if so assume that the cursor can be set to its previous location.
Example without the fix (|
marks the cursor position)
- foo
- bar|
- baz
Calling ltrim
will result in:
- foo
- bar
- baz|
But with the fix it will be:
- foo
- bar|
- baz
This is especially useful when calling rtrim
on a big file (to quickly get rid of some auto-indent on lines left blank), as without the fix it moves the cursor to the end of the file which is not convenient.