mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 11:52:25 +00:00
DEPM: handle undo when deleting spaces
Also, do not do any DEPM when the buffer is read-only.
This commit is contained in:
parent
dbe963a1ef
commit
2dc62d0405
@ -301,13 +301,13 @@ public:
|
|||||||
|
|
||||||
/// delete double spaces, leading spaces, and empty paragraphs around old cursor.
|
/// delete double spaces, leading spaces, and empty paragraphs around old cursor.
|
||||||
/// \retval true if a change has happened and we need a redraw.
|
/// \retval true if a change has happened and we need a redraw.
|
||||||
/// FIXME: replace Cursor with DocIterator. This is not possible right
|
/// Handles undo.
|
||||||
/// now because recordUndo() is called which needs a Cursor.
|
|
||||||
static bool deleteEmptyParagraphMechanism(Cursor & cur,
|
static bool deleteEmptyParagraphMechanism(Cursor & cur,
|
||||||
Cursor & old, bool & need_anchor_change);
|
Cursor & old, bool & need_anchor_change);
|
||||||
|
|
||||||
/// delete double spaces, leading spaces, and empty paragraphs
|
/// delete double spaces, leading spaces, and empty paragraphs
|
||||||
/// from \first to \last paragraph
|
/// from \first to \last paragraph
|
||||||
|
/// Does NOT handle undo (responsibility of the caller)
|
||||||
void deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool trackChanges);
|
void deleteEmptyParagraphMechanism(pit_type first, pit_type last, bool trackChanges);
|
||||||
|
|
||||||
/// To resolve macros properly the texts get their DocIterator.
|
/// To resolve macros properly the texts get their DocIterator.
|
||||||
|
@ -819,6 +819,10 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
|
|||||||
Paragraph & oldpar = old.paragraph();
|
Paragraph & oldpar = old.paragraph();
|
||||||
bool const trackChanges = cur.buffer()->params().track_changes;
|
bool const trackChanges = cur.buffer()->params().track_changes;
|
||||||
|
|
||||||
|
// We do not do anything on read-only documents
|
||||||
|
if (cur.buffer()->isReadonly())
|
||||||
|
return false;
|
||||||
|
|
||||||
// We allow all kinds of "mumbo-jumbo" when freespacing.
|
// We allow all kinds of "mumbo-jumbo" when freespacing.
|
||||||
if (oldpar.isFreeSpacing())
|
if (oldpar.isFreeSpacing())
|
||||||
return false;
|
return false;
|
||||||
@ -879,6 +883,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
|
|||||||
|
|
||||||
// Remove spaces and adapt cursor.
|
// Remove spaces and adapt cursor.
|
||||||
if (num_spaces > 0) {
|
if (num_spaces > 0) {
|
||||||
|
old.recordUndo();
|
||||||
int const deleted =
|
int const deleted =
|
||||||
deleteSpaces(oldpar, from, to, num_spaces, trackChanges);
|
deleteSpaces(oldpar, from, to, num_spaces, trackChanges);
|
||||||
// correct cur position
|
// correct cur position
|
||||||
|
Loading…
Reference in New Issue
Block a user