Bug 409940 - Undo cursor move
Summary: Undo cursor move
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: part (show other bugs)
Version: 18.12.3
Platform: Ubuntu Linux
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-18 09:57 UTC by Marcos Dione
Modified: 2022-01-14 20:21 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcos Dione 2019-07-18 09:57:26 UTC
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.
Comment 1 mickael.bosch 2020-03-08 21:27:06 UTC
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?
Comment 2 Dominik Haumann 2020-03-25 22:22:45 UTC
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?
Comment 3 Waqar Ahmed 2022-01-14 20:21:06 UTC
Kate since 21.04 maintains a history of last locations that you can jump to. Look for buttons to the left of tab bar.