[KRichTextEdit] Make sure headings don't mess with undo stack
ClosedPublic

Authored by poboiko on Apr 18 2020, 10:54 PM.

Details

Summary

This patch ensures that everything related to headings is undoable
with a single Ctrl+Z. It also adds tests for the following use cases
(ensuring those are undoable with a single undo command):

  1. Make line a heading
  2. Creating a newline after a heading
  3. Merging a heading and non-heading line with Delete key
  4. The same, with Backspace key
Test Plan

make && ctest

Diff Detail

Repository
R310 KTextWidgets
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
poboiko created this revision.Apr 18 2020, 10:54 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptApr 18 2020, 10:54 PM
poboiko requested review of this revision.Apr 18 2020, 10:54 PM
dfaure requested changes to this revision.Apr 19 2020, 9:23 AM
dfaure added inline comments.
src/widgets/krichtextedit.cpp
572 ↗(On Diff #80508)

Where is the corresponding beginEditBlock()?

This revision now requires changes to proceed.Apr 19 2020, 9:23 AM
poboiko added inline comments.Apr 19 2020, 10:23 AM
src/widgets/krichtextedit.cpp
572 ↗(On Diff #80508)

joinPreviousEditBlock in a way acts as beginEditBlock (see https://doc.qt.io/qt-5/qtextcursor.html#joinPreviousEditBlock).

The intent here was following: if user pressed Return, a new line (empty QTextBlock) is inserted somewhere inside QTextEdit::keyPressEvent. I want to also change the cursor style, and I want this action to be treated together with this QTextBlock insertion as a single action in undo stack. That's what joinPreviousEditBlock / endEditBlock combo does (semantically, this "previous edit block" is QTextBlock insertion inside QTextEdit::keyPressEvent)

dfaure accepted this revision.Apr 19 2020, 10:37 AM

Oh I see. Thanks, I didn't know that method.

This revision is now accepted and ready to land.Apr 19 2020, 10:37 AM
This revision was automatically updated to reflect the committed changes.