-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Description of the Issue
For users not using the Notepad++ autoComplete files as intended, but rather putting large strings of non-typical word characters to use autocomplete as a form of code snippet provider, the addition of the "fx" icon has causes some sorting issues.
This is because the default separator we use ? is higher in the ASCII table than some other non-typical word characters so it is sorted latter. For example, see the community discussion.
In that example autocomplete is providing a list like:
print_r(get_class_methods(get_class($var)));die();
print_r
when the desire is the lone print_r comes first. This is because internally, the ?1000 tag is appended for the "fx" image icon as per using the default Scintilla SCI_AUTOCSETTYPESEPARATOR which is the ?. So the list internal to Notepad++ is really:
print_r?1000
print_r(get_class_methods(get_class($var)));die();?1000
and after column by column sorting, the ( (ASCII 40 (\x28)) from the second item compared to the ? (ASCII 63 (\x3F)) of the first item, .. they are switched in the sort since 40 < 63, i.e., parenthesis comes before question mark even though the question mark isn't displayed in the Autocomplete output window. So the output of the autocomplete window appears "incorrectly" sorted.
Steps to Reproduce the Issue
- Using the autoComplete/python.xml file as an example, add a line directly under the current
printKeyWord so it looks like the following:
<KeyWord name="print" />
<KeyWord name="print(somestuff)" />- Set Notepad++ language to Python
- Ensure Settings => Preferences => Auto-Completion is enabled (default values):
- Type
prand observe:
print(somestuff) is sorted before print and as described above this is expected, but not desirable.
Expected Behavior
Sort
print
print(somestuff)
Fix
This is easily fixed as pointed out by @pryrt in the Community link above. Just use a lower ASCII character as the SCI_AUTOCSETTYPESEPARATOR instead of the default ? and I think "Record Separator" (ASCII 30 (\x1E)) is a good choice by name and by sort order - lower than all visible ASCII characters one could think to put in the autocomplete XML files.
I have tested and will submit a pull request. But PLEASE do your own testing as well!
Debug Information
Notepad++ v8.3.1 (32-bit)
Build time : Feb 13 2022 - 15:35:09
Path : C:\Downloads\32\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : ON
Cloud Config : OFF
OS Name : Windows 10 Enterprise (64-bit)
OS Version : 2009
OS Build : 19042.1526
Current ANSI codepage : 1252
Plugins :

