[LyX/2.4.x] Consider CT in dash mechanism (#13062)

Richard Kimberly Heck rikiheck at lyx.org
Mon Jun 10 19:23:59 UTC 2024


commit 8b0546dfe7a1349f601473d874f2b08ce54ffe70
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Sat May 11 13:07:32 2024 +0200

    Consider CT in dash mechanism (#13062)
    
    (cherry picked from commit fe4f0dbf0b37c413994bbfa780a833b1c041a433)
---
 src/Text.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/Text.cpp b/src/Text.cpp
index d5a1069fa1..0adc763c2f 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -1127,12 +1127,15 @@ void Text::insertChar(Cursor & cur, char_type c)
 	if (!cur.paragraph().isPassThru() && owner_->lyxCode() != IPA_CODE &&
 	    cur.real_current_font.fontInfo().family() != TYPEWRITER_FAMILY &&
 	    c == '-' && pos > 0) {
-		if (par.getChar(pos - 1) == '-') {
+		pos_type prev_pos = pos - 1;
+		while (prev_pos > 0 && par.isDeleted(prev_pos))
+			--prev_pos;
+		if (!par.isDeleted(prev_pos) && par.getChar(prev_pos) == '-') {
 			// convert "--" to endash
-			par.eraseChar(pos - 1, cur.buffer()->params().track_changes);
+			par.eraseChar(prev_pos, cur.buffer()->params().track_changes);
 			c = 0x2013;
 			pos--;
-		} else if (par.getChar(pos - 1) == 0x2013) {
+		} else if (!par.isDeleted(prev_pos) && par.getChar(prev_pos) == 0x2013) {
 			// convert "---" to emdash
 			par.eraseChar(pos - 1, cur.buffer()->params().track_changes);
 			c = 0x2014;


More information about the lyx-cvs mailing list