From 548093449967bb84aaf112df736428681657c528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= Date: Fri, 8 Mar 2024 07:56:22 +1100 Subject: Bug [#2403]. Add SC_AUTOCOMPLETE_SELECT_FIRST_ITEM. This option always selects the first item in the autocompletion list. --- test/simpleTests.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test') diff --git a/test/simpleTests.py b/test/simpleTests.py index 72007f86a..900f97faf 100644 --- a/test/simpleTests.py +++ b/test/simpleTests.py @@ -3129,6 +3129,28 @@ class TestAutoComplete(unittest.TestCase): self.assertEqual(self.ed.AutoCActive(), 0) + def testAutoSelectFirstItem(self): + self.assertEqual(self.ed.AutoCActive(), 0) + + self.ed.AutoCSetOrder(self.ed.SC_ORDER_CUSTOM) + + # without SC_AUTOCOMPLETE_SELECT_FIRST_ITEM option + self.ed.SetSel(3, 3) + self.ed.AutoCShow(3, b"aaa1 bbb1 xxx1") + # automatically selects the item with the entered prefix xxx + self.ed.AutoCComplete() + self.assertEqual(self.ed.Contents(), b"xxx1\n") + + # with SC_AUTOCOMPLETE_SELECT_FIRST_ITEM option + self.ed.AutoCSetOptions(2, 0) + self.ed.SetSel(3, 3) + self.ed.AutoCShow(3, b"aaa1 bbb1 xxx1") + # selects the first item regardless of the entered prefix and replaces the entered xxx + self.ed.AutoCComplete() + self.assertEqual(self.ed.Contents(), b"aaa11\n") + + self.assertEqual(self.ed.AutoCActive(), 0) + def testAutoCustomSort(self): # Checks bug #2294 where SC_ORDER_CUSTOM with an empty list asserts # https://sourceforge.net/p/scintilla/bugs/2294/ -- cgit v1.2.3