aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/simpleTests.py
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2025-02-01 14:43:22 +1100
committerNeil <nyamatongwe@gmail.com>2025-02-01 14:43:22 +1100
commitf54fd2019dd648b29a80ec7429833ab546d3a428 (patch)
tree231bebba7db25fccf798340bdd908f28fd504c26 /test/simpleTests.py
parentdb6332fa9933244c45c44063afbdcccb462cfc03 (diff)
downloadscintilla-mirror-f54fd2019dd648b29a80ec7429833ab546d3a428.tar.gz
Serialize selection type and ranges with SCI_GETSELECTIONSERIALIZED and
SCI_SETSELECTIONSERIALIZED.
Diffstat (limited to 'test/simpleTests.py')
-rw-r--r--test/simpleTests.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/simpleTests.py b/test/simpleTests.py
index ce67edfde..867c0ebbc 100644
--- a/test/simpleTests.py
+++ b/test/simpleTests.py
@@ -2242,6 +2242,39 @@ class TestMultiSelection(unittest.TestCase):
self.assertEqual(self.ed.Contents(), b'a 1')
self.assertEqual(self.textOfSelection(0), b' ')
+ def testSelectionSerialization(self):
+ self.ed.SetContents(b"a")
+ self.ed.SetSelection(0, 1)
+ self.assertEqual(self.ed.GetSelectionSerialized(), b'1-0')
+ self.ed.SetSelection(1, 1)
+ self.assertEqual(self.ed.GetSelectionSerialized(), b'1')
+ self.ed.SetSelectionNAnchorVirtualSpace(0, 2)
+ self.ed.SetSelectionNCaretVirtualSpace(0, 3)
+ self.assertEqual(selectionRepresentation(self.ed, 0), "1+2v-1+3v")
+ self.assertEqual(self.textOfSelection(0), b'')
+ self.assertEqual(self.ed.GetSelectionSerialized(), b'1v2-1v3')
+ self.ed.SetSelectionSerialized(0, b'1-0')
+ self.assertEqual(self.ed.MainSelection, 0)
+ self.assertEqual(self.ed.Anchor, 1)
+ self.assertEqual(self.ed.CurrentPos, 0)
+ self.assertEqual(self.ed.GetSelectionNAnchor(0), 1)
+ self.assertEqual(self.ed.GetSelectionNCaret(0), 0)
+
+ def testSelectionSerializationOutOfBounds(self):
+ # Try setting selections that extend past document end through serialized form
+ # and check that the selection is limited to the document.
+ self.ed.SetContents(b"a")
+ self.ed.SetSelectionSerialized(0, b'200-0')
+ self.assertEqual(self.ed.GetSelectionSerialized(), b'1-0')
+
+ # Retain virtual space
+ self.ed.SetSelectionSerialized(0, b'0v1-200')
+ self.assertEqual(self.ed.GetSelectionSerialized(), b'0v1-1')
+
+ # Drop identical ranges, but touching empty range survives
+ self.ed.SetSelectionSerialized(0, b'0-200,300-400,500-600')
+ self.assertEqual(self.ed.GetSelectionSerialized(), b'0-1,1')
+
class TestModalSelection(unittest.TestCase):