commit dff0c5729e6eec4c799f60171e4d0a377327ab10
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Fri Dec 21 15:36:55 2018 +0100
Make DEPM respect current cursor position.
Spaces are now conserved when they surround current cursor. Examples:
abc | def
becomes
abc | def
after DEPM and
abc |
is kept as it is.
Fixes ticket #11412.
---
src/Text2.cpp | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/Text2.cpp b/src/Text2.cpp
index 17f32ad..cb394c2 100644
--- a/src/Text2.cpp
+++ b/src/Text2.cpp
@@ -845,7 +845,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
&& old.pos() == cur[depth].pos();
// If the chars around the old cursor were spaces, delete some of
- // them , but only if the cursor has really moved.
+ // them, but only if the cursor has really moved.
if (!same_par_pos) {
// find range of spaces around cursors
int from = old.pos();
@@ -863,6 +863,9 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
if (from != to && from > 0 && to < oldpar.size())
++from;
+ if (same_par && cur.pos() > from && cur.pos() < to)
+ ++from;
+
// Remove spaces and adapt cursor.
if (from < to) {
oldpar.eraseChars(from, to,
cur.buffer()->params().track_changes);
@@ -879,7 +882,7 @@ bool Text::deleteEmptyParagraphMechanism(Cursor & cur,
}
}
- // only do our magic if we changed paragraph
+ // only do our other magic if we changed paragraph
if (same_par)
return false;