Skip to content

Fix autocomplete case insensitive list #11187

@mpheath

Description

@mpheath

Issue mentioned at Notepad++ community topic Issue with autocompletion - comparing 7.3.3 and 8.3.

Excerpts of autocomplete results of Tra mentioned from my reply:

7.3.3 autocomplete displays:

TraceLine
TransformAndDrawLineList

8.3 autocomplete displays:

TRACE.ALL
TRACE.FLOODFILL
TRACE.FLOODFILLENT
TRACE.GRATE
TRACE.OPAQUE
TRACE.PLAYER
TRACE.PLAYERCLIP
TRACE.SHOT
TRACE.SMOKEBOMB
TRACE.SOLID
TRACE.VISIBLE
TRACE.WATER

These autocomplete lists are based on creation of a UDL named test, set with defaults, and this autocomplete xml file named as test.xml.

Need to set 1 to 3 in:

Preferences -> Auto-Completion -> From 3 th character

else you need to cancel autocomplete on the 2nd character and then type the 3rd character to display the autocomplete list for the 3rd character.

Set language to test in Language menu.

The autocomplete list for T can be different to the autocomplete list for Tra which important to note.

8.3 should not display that list for either ignorecase=no or ignorecase=yes, in my opinion.

  • If ignorecase=no and TRA was typed, then OK, though Tra was typed.
  • If ignorecase=yes, I would expect to see also TraceLine and TransformAndDrawLineList in the list.

This lead me to debug with help from Michael Vincent who pointed to the source file with the issue. I have considered with testing to have found a fix. Now the autocomplete list has a suitable selection. The results from getWordArray() was inadequate because of the search flags being used. canStop condition did not help either as the list is unsorted (yet alone case in...sensitivity) so I cannot see how it can break out of the for loop at the correct iteration.

Patch to fix the issue:

diff --git a/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp b/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp
index e7cf9efc..81e363ca 100644
--- a/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp
+++ b/PowerEditor/src/ScintillaComponent/AutoCompletion.cpp
@@ -164,7 +164,6 @@ bool AutoCompletion::showApiAndWordComplete()
 
 	// Add keywords to word array
 
-	bool canStop = false;
 	for (size_t i = 0, kwlen = _keyWordArray.size(); i < kwlen; ++i)
 	{
 		int compareResult = 0;
@@ -183,12 +182,6 @@ bool AutoCompletion::showApiAndWordComplete()
 		{
 			if (!isInList(_keyWordArray[i], wordArray))
 				wordArray.push_back(_keyWordArray[i]);
-			canStop = true;
-		}
-		else if (canStop)
-		{
-			// Early out since no more strings will match
-			break;
 		}
 	}
 
@@ -233,7 +226,7 @@ void AutoCompletion::getWordArray(vector<generic_string> & wordArray, TCHAR *beg
 
 	size_t docLength = _pEditView->execute(SCI_GETLENGTH);
 
-	int flags = SCFIND_WORDSTART | SCFIND_MATCHCASE | SCFIND_REGEXP | SCFIND_POSIX;
+	int flags = SCFIND_WORDSTART | _ignoreCase ? 0 : SCFIND_MATCHCASE | SCFIND_REGEXP | SCFIND_POSIX;
 
 	_pEditView->execute(SCI_SETSEARCHFLAGS, flags);
 	intptr_t posFind = _pEditView->searchInTarget(expr.c_str(), expr.length(), 0, docLength);

If you want the patch as a PR, let me know, as I have a branch ready. The guidelines mentions that an issue is needed before a PR can be accepted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions