From 96725481f39c7b2311435b3c088760c87bc0b618 Mon Sep 17 00:00:00 2001
From: ale rimoldi <ale@graphicslab.org>
Date: Sat, 6 Sep 2025 17:13:52 +0200
Subject: selectText() accepts 0 as length and just sets the cursor position;
 always set the selection at the end of the selection


diff --git a/scribus/plugins/scriptplugin/cmdtext.cpp b/scribus/plugins/scriptplugin/cmdtext.cpp
index de47752b8..bd6d35393 100644
--- a/scribus/plugins/scriptplugin/cmdtext.cpp
+++ b/scribus/plugins/scriptplugin/cmdtext.cpp
@@ -1273,21 +1273,10 @@ PyObject *scribus_selecttext(PyObject* /* self */, PyObject* args)
 		PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot select text in a non-text frame", "python error").toLocal8Bit().constData());
 		return nullptr;
 	}
-	/* FIXME: not sure if we should make this check or not
-	if (start > ende)
-	{
-		PyErr_SetString(PyExc_ValueError, QString("Selection start > selection end").toLocal8Bit().constData());
-		return nullptr;
-	}
-	*/
 	item->itemText.deselectAll();
-	if (selcount == 0)
-	{
-		item->HasSel = false;
-		Py_RETURN_NONE;
-	}
 	item->itemText.select(start, selcount, true);
-	item->HasSel = true;
+	item->itemText.setCursorPosition(start + selcount);
+	item->HasSel = (selcount != 0);
 
 	Py_RETURN_NONE;
 }
