Skip to content

New Auto-Complete icons causes sort issues for edge use cases #11233

@vinsworldcom

Description

@vinsworldcom

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

  1. Using the autoComplete/python.xml file as an example, add a line directly under the current print KeyWord so it looks like the following:
		<KeyWord name="print" />
		<KeyWord name="print(somestuff)" />
  1. Set Notepad++ language to Python
  2. Ensure Settings => Preferences => Auto-Completion is enabled (default values):

image

  1. Type pr and observe:

image

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 :

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