Autocomplete Items Order Issue
Something has to have changed.
It did. I explained it above. The commit is here. I authored it.
Using non-word characters in custom autocomplete language files was not part of my testing. I would argue that the autocomplete files are for “functions” not “code snippets”:
- code snippet:
Use a snippet plugin for the latter.
That said, I think that it shouldn’t have been sorted with the ?1000
That’s tough, I agree I’d like to add it later, but the code structure (as-is) really doesn’t allow that. As we loop through the “functions” from the autocomplete language file, we add the
?1000since later those are merged with the word completions found in the current document. If we wait until the merge, I couldn’t see a way to identify the “functions” and add the icon identifier. Then, the whole merged list is sorted - which means the
?1000are in the items during the sort. And I’m guessing
(in the sort routine.
((0x28) comes before
?(0x3F) in ASCII order, so it really should be sorted before by any normal lexicographical sort function.
Since you were involved in that old ticket, could you maybe suggest to Don that instead of
?1000, just use a low-ASCII control character (0x01-0x1F – obviously not 0x00 NUL, since that would end the string) – that way it would sort after the words found in the current document, but before any visible ASCII character when sorting the function-list keywords. That would fix the OP issue
maybe suggest to Don that instead of ?1000, just use a low-ASCII control character (0x01-0x1F
?is the default in Scintilla so that’s what I used. I didn’t bother trying a low control character for sort order since
?is a non-word character - who would’ve thought it could even be used in the Notepad++ autocomplete/ directory files?
Hmm… I guess OP?
You present a good idea. I can try some testing. If it works, it’s a simple enough change.
Lycan Thrope last edited by
I installed portable 8.3.1 to test whether what I know changed or not, and after copying my own UDL, FunctionList, Autocomplete and overridemap files over to the portable it works as it should.
Granted, by the way, who decided to include that
fxglyph in the Autocomplete keywords and function list? As screenshot shows for me, the only thing different is that glyph, the list still sorts lexocographically.
That glyph is now a distraction. :)
Alan Kilborn last edited by
@michael-vincent If Notepad++ could autocomplete snippets - would be very handy to write faster things.
For example, this item
inserts each function on the new line.
I used hexadecimal XML entities in the
php.xmlautocomplete file, except spaces
that broke the autocomplete box behaviour:
Hexadecimal Decimal Unicode Name
LINE FEED (LF)
CARRIAGE RETURN (CR)
It’s useful for me. It could be great if somebody could remain the same functionality.
My current Notepad++ v8.3.1 autocompletion behaves the same as in the previous version, except for the order of items in the autocomplete results box.
Yes, what you are describing is the EXACT use case for the code snippets plugins I mentioned and NOT the intended use of the Notepad++/autoComplete/ files.
But alas, @PeterJones had a good suggestion and ASCII record separator 30 (\x1E) seems to be a good alternative that is “lower” in sort order than all visible ASCII characters so should fix the sorting problem if I can get an issue and pull request accepted.
It’s not just for the snippet-abuse of auto-complete.
if I can get an issue and pull request accepted.
If you need additional justification: Perfectly valid autocomplete word characters (
9) are sorted incorrectly because of the use of
?as the image separator character:
The following three keywords are sorted in lexicographical sort order. They only have valid word characters (
\w) in their keyword. But they still sort incorrectly in the function list:
print_r print_r0 print_rand
print_rshould always come before anything longer that starts with the same sequence.
But because asc(
0)=48=0x30 is less than asc(
?)=63=0x3F, the auto-complete will list
print_r. This is a bug in the current implementation.
<?xml version="1.0" encoding="UTF-8" ?> <!-- @author Geoffray Warnants - http://www.geoffray.be @version 1.35.20100625 --> <NotepadPlus> <AutoComplete> <KeyWord name="print_r" func="yes"> <Overload retVal="mixed"> <Param name="mixed expression"/> <Param name="[bool return=false]"/> </Overload> </KeyWord> <KeyWord name="print_r0" func="yes"> <Overload retVal="mixed"> <Param name="argument"/> </Overload> </KeyWord> <KeyWord name="print_rand" func="yes"/> </AutoComplete> </NotepadPlus>
Feel free to use this image and minimized auto-completion file in your issue report as justification.
Notepad++ v8.3.1 (64-bit)
Build time : Feb 13 2022 - 15:41:12
Path : C:\usr\local\apps\npp\npp.8.3.1.portable.x64\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 : mimeTools.dll NppConverter.dll NppExport.dll
But I definitely agree, @Valery-Bogomolov should learn how to use one of the code-snippet tools (I would personally recommend Michael’s fork of the QuickText plugin, as I found that the most intuitive of the snippet-plugins for my use-case), rather than continuing to abuse the auto-complete files for things it wasn’t intended to do.
@peterjones I’m sorry for the “snippet-abuse”, I just wanted to get the most from the Npp’s auto-complete interface. I experimented with autocomplete a lot before developing the parser that generates KeyWords for my favorite language PHP. I wrote about it here
Unexpectedly, I figured out that I was able, for example, to write faster SQL queries code rather than using any other editor for that.
FingerText is not compatible with my configured Notepad++, QuickText is not convenient for me to use, but I use it. NppSnippets is a great plugin, but I have to search for a specific item in a dialog to insert a snippet and it takes some time.
Alan Kilborn last edited by
@michael-vincent Thank you for the great work, but personally, I don’t like the new UX of the autocomplete: the
fxicon is really distracting and I have to look down a couple of lines to see the first result. I would prefer to have the old autocomplete if it could be possible, sorry
Valery Bogomolov last edited by Valery Bogomolov
This post is deleted!
@michael-vincent Ok, now it works. I compared it with the old autocomplete version and the results seem to be the same.
fxicon is everywhere. There is a
func="no"attribute in XML that describes the KeyWord, and the
funcattribute is not always required. There could be some language expression like
return, but it’s not
The “fx” distinguishes the option comes from an autocomplete/*.xml file versus a word from the current file when both word and API autocomplete is active.
Scintilla autocomplete has a lot to be desired and Notepad++ does the best it can with it, but plugins can use autocomplete too (e.g., QuickText, TagLEET, I have PythonScripts that do it to provide Python-IDE-like features with jedi). Only you can’t merge the lists - only 1 autocomplete is active at any time. So which suggestion is coming from what source?
TagLEET global tags file:
TagLEET local tags file:
PythonScript custom Python IDE:
It’d be nice to see them all in the same list, but alas, each time a character is typed and a best match is found, whatever Notepad++ / Plugin matches best displays it’s abbreviated list. The Icons help determine where in the heck this suggestion is coming from.
This is no different than most other editors that offer autocomplete (VS Code example)