r22247 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Wed Dec 13 19:15:04 UTC 2017


Author: jghali
Date: Wed Dec 13 19:15:04 2017
New Revision: 22247

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22247
Log:
#15070: Incorrect cursor position after undoing or redoing text action

Modified:
    trunk/Scribus/scribus/pageitem.cpp

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22247&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp	(original)
+++ trunk/Scribus/scribus/pageitem.cpp	Wed Dec 13 19:15:04 2017
@@ -6510,13 +6510,18 @@
 {
 	int start = ss->getInt("START");
 	QString text = ss->get("TEXT");
+
+	itemText.deselectAll();
 	if (isUndo)
 	{
 		itemText.select(start, text.length());
 		asTextFrame()->deleteSelectedTextFromFrame();
 	}
 	else
+	{
 		itemText.insertChars(start, text, true);
+		itemText.setCursorPosition(start + text.length());
+	}
 }
 
 void PageItem::restorePasteText(SimpleState *ss, bool isUndo)
@@ -6525,13 +6530,18 @@
 	if (!is)
 		qFatal("PageItem::restorePasteText: dynamic cast failed");
 	int start = is->getInt("START");
-	if (isUndo)
-	{
-		itemText.select(start,is->getItem().length());
+
+	itemText.deselectAll();
+	if (isUndo)
+	{
+		itemText.select(start, is->getItem().length());
 		asTextFrame()->deleteSelectedTextFromFrame();
 	}
 	else
+	{
 		itemText.insert(start, is->getItem());
+		itemText.setCursorPosition(start + is->getItem().length());
+	}
 }
 
 void PageItem::restoreColumnsGap(SimpleState *ss, bool isUndo)
@@ -6674,10 +6684,13 @@
 		qFatal("PageItem::restoreDeleteFrameText: dynamic cast failed");
 	QString text = is->get("TEXT_STR");
 	int start = is->getInt("START");
+
+	itemText.deselectAll();
 	if (isUndo)
 	{
 		itemText.insertChars(start, text);
 		itemText.applyCharStyle(start, text.length(), is->getItem());
+		itemText.setCursorPosition(start + text.length());
 		invalid = true;
 		invalidateLayout();
 	}
@@ -6695,10 +6708,13 @@
 	if (!is)
 		qFatal("PageItem::restoreDeleteFrameParagraph: dynamic cast failed");
 	int start = is->getInt("START");
+	
+	itemText.deselectAll();
 	if (isUndo)
 	{
 		itemText.insertChars(start, SpecialChars::PARSEP);
 		itemText.applyStyle(start, is->getItem());
+		itemText.setCursorPosition(start + 1);
 		invalid = true;
 		invalidateLayout();
 	}
@@ -6714,14 +6730,18 @@
 {
 	QString text = ss->get("TEXT_STR");
 	int start = ss->getInt("START");
-	if (isUndo)
-	{
-		itemText.deselectAll();
+
+	itemText.deselectAll();
+	if (isUndo)
+	{
 		itemText.select(start, text.length());
 		asTextFrame()->deleteSelectedTextFromFrame();
 	}
 	else
+	{
 		itemText.insertChars(start, text);
+		itemText.setCursorPosition(start + text.length());
+	}
 }
 
 void PageItem::restoreInsertFrameParagraph(SimpleState *ss, bool isUndo)
@@ -6730,6 +6750,8 @@
 	if (!is)
 		qFatal("PageItem::restoreInsertFrameParagraph: dynamic cast failed");
 	int start = is->getInt("START");
+	
+	itemText.deselectAll();
 	if (isUndo)
 	{
 		itemText.select(start, 1);
@@ -6739,6 +6761,7 @@
 	else
 	{
 		itemText.insertChars(start, SpecialChars::PARSEP);
+		itemText.setCursorPosition(start + 1);
 		invalid = true;
 		invalidateLayout();
 	}




More information about the scribus-commit mailing list