Bug 402899

Summary: kate does not remember the cursor position of last view or edit
Product: [Applications] kate Reporter: Wolfgang Bauer <wbauer1>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: a.samirh78, justin.zobel, waqar.17a
Priority: NOR    
Version First Reported In: 18.12.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Wolfgang Bauer 2019-01-05 17:20:03 UTC
SUMMARY
kate 17.12.3 remembered the current cursor position and restored it when reloading the text file, but since 18.04 the cursor is always at the top.

Seems to only happen in an unnamed session though, when explictly saving the session and restoring it later the cursor position is restored too.

If I load a file last edited with 17.12.3 in a newer version, it seems to restore the cursor position as well.

STEPS TO REPRODUCE
1. run kate
2. enter some text, move/keep the cursor on some arbitrary position (other then at the beginning of the first line) and save it
3. restart kate and load the text file

OBSERVED RESULT
The text cursor is on the beginning of the first line.

EXPECTED RESULT
The cursor should be where it was left when saving/closing kate.

KDE Plasma Version: 5.14.5
KDE Frameworks Version: 5.53.0
Qt Version: 5.12.0

ADDITIONAL INFORMATION
Downgrading kate to 17.12.3 makes it work again, with the very same KDE Frameworks/ktexteditor and Qt versions.

Originally reported at https://bugzilla.opensuse.org/show_bug.cgi?id=1120845, but I don't think it is distribution specific.
Comment 1 Ahmad Samir 2019-03-22 19:20:32 UTC
It seems this issue is caused by this commit:
https://cgit.kde.org/kate.git/commit/?id=e3ece7bd45d2743b3c36ad856abd12ac9ba282d6

closeDocument(untitledDoc) isn't called, so this chain doesn't happen: KateDocManager::documentsDeleted -> KateViewManager::documentsDeleted -> KateViewManager::createView, the latter calls KTextEditor::View::readSessionConfig() to restore the cursor position.
Comment 2 Justin Zobel 2020-10-29 01:11:34 UTC
(In reply to Ahmad Samir from comment #1)
> It seems this issue is caused by this commit:
> https://cgit.kde.org/kate.git/commit/
> ?id=e3ece7bd45d2743b3c36ad856abd12ac9ba282d6
> 
> closeDocument(untitledDoc) isn't called, so this chain doesn't happen:
> KateDocManager::documentsDeleted -> KateViewManager::documentsDeleted ->
> KateViewManager::createView, the latter calls
> KTextEditor::View::readSessionConfig() to restore the cursor position.

I have confirmed this is still an issue.

Ahmad would you be interested in providing a patch to fix this behaviour?

If you would like to submit a merge request to fix it, you can do so here: https://invent.kde.org/utilities/kate/-/merge_requests
Comment 3 Waqar Ahmed 2021-10-11 07:35:13 UTC
Can someone test if this bug is still present?
Comment 4 Waqar Ahmed 2022-01-22 13:46:48 UTC
Since the referenced commit got mostly reverted and I can no longer reproduce this bug => fixed