aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/ScintillaHistory.html8
-rw-r--r--src/AutoComplete.cxx5
-rw-r--r--test/simpleTests.py40
3 files changed, 51 insertions, 2 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html
index 0cb250da5..ca0fbfff1 100644
--- a/doc/ScintillaHistory.html
+++ b/doc/ScintillaHistory.html
@@ -588,8 +588,12 @@
The wParam (length) argument to SCI_GETTEXT and SCI_GETCURLINE also omits the NUL.
This is more consistent with other APIs.
</li>
- <ul>
- <h2>Releases</h2>
+ <li>
+ Fix assertion failure with autocompletion list when order is SC_ORDER_CUSTOM
+ or SC_ORDER_PERFORMSORT and the list is empty.
+ <a href="https://sourceforge.net/p/scintilla/bugs/2294/">Bug #2294</a>.
+ </li>
+ </ul>
<h3>
<a href="https://www.scintilla.org/scintilla514.zip">Release 5.1.4</a>
</h3>
diff --git a/src/AutoComplete.cxx b/src/AutoComplete.cxx
index 47e942561..2bf88aa23 100644
--- a/src/AutoComplete.cxx
+++ b/src/AutoComplete.cxx
@@ -115,6 +115,11 @@ struct Sorter {
Sorter(AutoComplete *ac_, const char *list_) : ac(ac_), list(list_) {
int i = 0;
+ if (!list[i]) {
+ // Empty list has a single empty member
+ indices.push_back(i); // word start
+ indices.push_back(i); // word end
+ }
while (list[i]) {
indices.push_back(i); // word start
while (list[i] != ac->GetTypesep() && list[i] != ac->GetSeparator() && list[i])
diff --git a/test/simpleTests.py b/test/simpleTests.py
index 98ae2a3af..49b6061a4 100644
--- a/test/simpleTests.py
+++ b/test/simpleTests.py
@@ -2734,6 +2734,46 @@ class TestAutoComplete(unittest.TestCase):
self.assertEquals(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/
+ self.assertEquals(self.ed.AutoCGetOrder(), self.ed.SC_ORDER_PRESORTED)
+
+ self.ed.AutoCSetOrder(self.ed.SC_ORDER_CUSTOM)
+ self.assertEquals(self.ed.AutoCGetOrder(), self.ed.SC_ORDER_CUSTOM)
+
+ #~ self.ed.AutoCShow(0, b"")
+ #~ self.ed.AutoCComplete()
+ #~ self.assertEquals(self.ed.Contents(), b"xxx\n")
+
+ self.ed.AutoCShow(0, b"a")
+ self.ed.AutoCComplete()
+ self.assertEquals(self.ed.Contents(), b"xxx\na")
+
+ self.ed.AutoCSetOrder(self.ed.SC_ORDER_PERFORMSORT)
+ self.assertEquals(self.ed.AutoCGetOrder(), self.ed.SC_ORDER_PERFORMSORT)
+
+ self.ed.AutoCShow(0, b"")
+ self.ed.AutoCComplete()
+ self.assertEquals(self.ed.Contents(), b"xxx\na")
+
+ self.ed.AutoCShow(0, b"b a")
+ self.ed.AutoCComplete()
+ self.assertEquals(self.ed.Contents(), b"xxx\naa")
+
+ self.ed.AutoCSetOrder(self.ed.SC_ORDER_PRESORTED)
+ self.assertEquals(self.ed.AutoCGetOrder(), self.ed.SC_ORDER_PRESORTED)
+
+ self.ed.AutoCShow(0, b"")
+ self.ed.AutoCComplete()
+ self.assertEquals(self.ed.Contents(), b"xxx\naa")
+
+ self.ed.AutoCShow(0, b"a b")
+ self.ed.AutoCComplete()
+ self.assertEquals(self.ed.Contents(), b"xxx\naaa")
+
+ self.assertEquals(self.ed.AutoCActive(), 0)
+
def testWriteOnly(self):
""" Checks that setting attributes doesn't crash or change tested behaviour
but does not check that the changed attributes are effective. """