Sometimes when using the editor I hit the wrong button and I move the cursor to somewhere completely off the viewport. Confused, I try to go back to where I was, but I can't remember the line number, so with a little bit of luck I remember the layout of the file and/or the name of the function I was editing (yes, I develop in Kate!) and after some searching and oogling, I can return. Also, while searching (and maybe replacing) I see something I should fix. It would be nice if I could revisit the places that search showed me. I know that then I can set a bookmark (luckily C-b works in S and S&R) and then come back there, but more often than not I already have several bookmarks set (to the point that the message 'no more letters to assign' is no stranger to me :) So my proposal is to have another undo stack, but only for cursor positions (maybe only populated when big jumps happen, like C-End, while searching, etc), and a couple of shortcuts to navigate this stack.
I would like to implement this in Kate. How : - connect a slot to KTextEditor::View::cursorPositionChanged() - fill a map<KTextEditor::View, list<KTextEditor::Cursor>> in this slot - register the actions "undo move cursor" and "redo move cursor in the View menu with their associated shortcuts and the hardcoded shortcuts ctrl + "mouse previous/next button" - when the action is triggered, apply it on the current view and update the map[view] list accordingly. In a second commit: - allow to discard jumps when the relative cursor move is less than N lines - allow to limit the lists sizes (I doubt this will save a lot of memory but the original post only suggests to undo few bad keystrokes). On my own wishlist: - allow to configure the mouse buttons actions but I did not see any easy option in the KDE framework. The Kate tab bar already use the "mouse previous/next button" but I don't use the tab bar, thus the "mouse previous/next button" are a good mouse shortcut for me. Any suggestions before I try this?
Hm, there already is a way in the code to jump to saved editing positions: https://github.com/KDE/ktexteditor/blob/master/src/document/katedocument.h#L406 I believe instead of adding yet another way of doing this, maybe this already works or can be reused?
Kate since 21.04 maintains a history of last locations that you can jump to. Look for buttons to the left of tab bar.