• Login
Community
  • Login

Autocomplete Items Order Issue

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
35 Posts 6 Posters 6.1k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V
    Valery Bogomolov
    last edited by Valery Bogomolov Feb 17, 2022, 5:46 PM Feb 17, 2022, 5:45 PM

    Hi!

    Thank you for the Notepad++ v8.3.1 update - it’s so much faster than the previous version. The only moment I’m struggling with is the new autocompletion. The order of items in the autocompletion box has changed and it’s not that useful for me anymore.

    For example, I have a few items with print_r function, and the autocomplete shows me items in descending order, but I need items in ascending order like in the screenshot.

    Is there a way I could configure the autocompletion order of words and functions by myself, or have the autocomplete functionality from the previous version of Npp?

    Npp_Autocomplete_Sorting_Issue.png

    Thank you!

    P M 2 Replies Last reply Feb 17, 2022, 5:51 PM Reply Quote 0
    • P
      PeterJones @Valery Bogomolov
      last edited by Feb 17, 2022, 5:51 PM

      @valery-bogomolov ,

      There isn’t a setting that I know of that would allow you to change the order it’s presented in, sorry.

      You would have to put in a feature request, as explained in the FAQ.

      As a workaround for the short term, you can just type a couple of down-arrows before hitting the completion key (TAB or ENTER, depending on your settings) to select the one you want. (Or, since you already have the entire word you want, just hit ESC instead of TAB or ENTER to cancel the auto-completion, because if you’ve already typed the whole word, there’s nothing left to complete.)

      V 1 Reply Last reply Feb 17, 2022, 6:13 PM Reply Quote 2
      • M
        Michael Vincent @Valery Bogomolov
        last edited by Michael Vincent Feb 17, 2022, 6:12 PM Feb 17, 2022, 6:11 PM

        @valery-bogomolov said in Autocomplete Items Order Issue:

        For example, I have a few items with print_r function

        Are you using a custom PHP autocomplete file? There are a lot of non-typical “word” characters that are included in your suggestions that don’t show up in mine:

        3a5c807a-68f7-42e6-b8ba-3ca3ef2b9ed1-image.png

        The cause is to add “fx” icon, Scintilla appends ?1000 to the end of the options that trigger that icon ID to be shown. When sorting a list with non-word characters, I’m guessing that ? comes after ( ; hence you new “experience”.

        Cheers.

        M V 2 Replies Last reply Feb 17, 2022, 6:18 PM Reply Quote 3
        • V
          Valery Bogomolov @PeterJones
          last edited by Feb 17, 2022, 6:13 PM

          @peterjones Thank you for the tips but in the previous version of Npp I could easily auto-complete print_r function without typing the whole word, but now the order of items has changed and I have to type the whole word constantly :)

          L P 2 Replies Last reply Feb 17, 2022, 6:18 PM Reply Quote 0
          • M
            Michael Vincent @Michael Vincent
            last edited by Feb 17, 2022, 6:18 PM

            @michael-vincent said in Autocomplete Items Order Issue:

            There are a lot of non-typical “word” characters that are included in your suggestions

            @Valery-Bogomolov

            If you’re trying to use the PHP autocomplete file as a “code snippets” provider, that’s going a bit beyond the typical use case. There are “code snippet” plugins that can provide long pieces of code - including non-typical word characters - that would probably work better for you.

            • FingetText
            • NppSnippets
            • QuickText

            Cheers.

            1 Reply Last reply Reply Quote 2
            • L
              Lycan Thrope @Valery Bogomolov
              last edited by Lycan Thrope Feb 17, 2022, 6:19 PM Feb 17, 2022, 6:18 PM

              @valery-bogomolov ,
              Something has to have changed. As @Michael-Vincent points out, and as far as I know, the Autocomplete goes by binary order, meaning capitals before lower case, certain punctuation before upper case letters and some in between upper case and lower case letters, so words that take a diffferent position are usually listed according to that ASCII order. I don’t see that that has changed. Of course, I’m not using that latest yet, as I haven’t updated. :(

              Lee

              M 1 Reply Last reply Feb 17, 2022, 6:36 PM Reply Quote 1
              • V
                Valery Bogomolov @Michael Vincent
                last edited by Feb 17, 2022, 6:26 PM

                @michael-vincent Here you can find my php.xml file

                https://github.com/CoreText/WordPress-Auto-complete-for-Notepad-Plus/blob/master/php.xml

                that has all PHP functions that I generated using a parser + I added my custom items and I had no issues with the previous autocomplete functionality of Npp, except was not able to autocomplete items with spaces, so I added tab character using XML entity and it works for me.

                I’ll read the FAQ and will try to describe the feature in the appropriate place.

                Thanks.

                1 Reply Last reply Reply Quote 1
                • P
                  PeterJones @Valery Bogomolov
                  last edited by Feb 17, 2022, 6:29 PM

                  @valery-bogomolov ,

                  Please understand that Autocomplete has been advertised as being able to auto-complete keywords that are made up of “word characters”: ASCII letters, ASCII numbers, and the _ underscore. If you try to extend its usage beyond that, you are moving into edge-case, non-guaranteed behavior. If it always worked that way for you before, you were lucky, but it was not guaranteed. You have now found the problem of relying on non-advertised/non-guaranteed functionality: it can change without notice.

                  For code snippets or templates, you should really use one of the plugins that @Michael-Vincent mentioned.

                  That said, I think that it shouldn’t have been sorted with the ?1000 (or if he was using that to keep the Fx ones separate from the word-completion ones, it should have been handled differently).

                  M 1 Reply Last reply Feb 17, 2022, 6:40 PM Reply Quote 3
                  • M
                    Michael Vincent @Lycan Thrope
                    last edited by Feb 17, 2022, 6:36 PM

                    @lycan-thrope said in 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”:

                    • function: print_r
                    • code snippet: print_r(get_class_methods(get_class($var)));die();

                    Use a snippet plugin for the latter.

                    Cheers.

                    L 1 Reply Last reply Feb 17, 2022, 7:16 PM Reply Quote 1
                    • M
                      Michael Vincent @PeterJones
                      last edited by Feb 17, 2022, 6:40 PM

                      @peterjones said in Autocomplete Items Order Issue:

                      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 ?1000 since 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 ?1000 are in the items during the sort. And I’m guessing ? comes after ( in the sort routine.

                      Cheers.

                      P 1 Reply Last reply Feb 17, 2022, 6:46 PM Reply Quote 1
                      • P
                        PeterJones @Michael Vincent
                        last edited by Feb 17, 2022, 6:46 PM

                        @michael-vincent ,

                        4e71340c-3d57-4196-a5ae-fe34206f9bea-image.png

                        Left paren ( (0x28) comes before ? (0x3F) in ASCII order, so it really should be sorted before by any normal lexicographical sort function.

                        M 1 Reply Last reply Feb 17, 2022, 6:48 PM Reply Quote 3
                        • M
                          Michael Vincent @PeterJones
                          last edited by Feb 17, 2022, 6:48 PM

                          @peterjones said in Autocomplete Items Order Issue:

                          Left paren ( (0x28) comes before ? (0x3F) in ASCII order, so it really should be sorted before by any normal lexicographical sort function.

                          Pretty sure that’s the answer then.

                          Cheers.

                          P V 2 Replies Last reply Feb 17, 2022, 6:59 PM Reply Quote 1
                          • P
                            PeterJones @Michael Vincent
                            last edited by Feb 17, 2022, 6:59 PM

                            @michael-vincent ,

                            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

                            M 1 Reply Last reply Feb 17, 2022, 7:03 PM Reply Quote 3
                            • M
                              Michael Vincent @PeterJones
                              last edited by Feb 17, 2022, 7:03 PM

                              @peterjones said in Autocomplete Items Order Issue:

                              maybe suggest to Don that instead of ?1000, just use a low-ASCII control character (0x01-0x1F

                              the ? 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.

                              Cheers.

                              1 Reply Last reply Reply Quote 3
                              • L
                                Lycan Thrope @Michael Vincent
                                last edited by Feb 17, 2022, 7:16 PM

                                @michael-vincent ,

                                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 fx glyph in the Autocomplete keywords and function list? As screenshot shows for me, the only thing different is that glyph, the list still sorts lexocographically.

                                NPP8_3_1portableAutoComplete.PNG

                                That glyph is now a distraction. :)

                                Lee

                                A 1 Reply Last reply Feb 17, 2022, 7:20 PM Reply Quote 2
                                • A
                                  Alan Kilborn @Lycan Thrope
                                  last edited by Feb 17, 2022, 7:20 PM

                                  @lycan-thrope said in Autocomplete Items Order Issue:

                                  who decided to include that fx glyph

                                  That would be @michael-vincent
                                  Or rather, ultimately, @don-ho

                                  1 Reply Last reply Reply Quote 1
                                  • V
                                    Valery Bogomolov @Michael Vincent
                                    last edited by Feb 17, 2022, 7:35 PM

                                    @michael-vincent If Notepad++ could autocomplete snippets - would be very handy to write faster things.

                                    For example, this item

                                    <KeyWord name="error_reporting(0);&#x0D;&#x0A;ini_set('display_errors',0);&#x0D;&#x0A;ini_set('display_startup_errors',0);&#x0D;&#x0A;"/>

                                    inserts each function on the new line.

                                    Before:
                                    Npp_Autocomplete_Snippet.png

                                    After:
                                    Npp_Autocomplete_Snippet_Result.png

                                    I used hexadecimal XML entities in the php.xml autocomplete file, except spaces &#x20; that broke the autocomplete box behaviour:

                                    Hexadecimal Decimal Unicode Name
                                    &#x09; or &#09; CHARACTER TABULATION
                                    &#x0A; or &#10; LINE FEED (LF)
                                    &#x0D; or &#13; CARRIAGE RETURN (CR)
                                    &#x20; or &#32; SPACE

                                    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.

                                    Cheers.

                                    M 1 Reply Last reply Feb 17, 2022, 7:39 PM Reply Quote 0
                                    • M
                                      Michael Vincent @Valery Bogomolov
                                      last edited by Feb 17, 2022, 7:39 PM

                                      @valery-bogomolov

                                      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.

                                      Cheers.

                                      P M 2 Replies Last reply Feb 17, 2022, 8:37 PM Reply Quote 4
                                      • P
                                        PeterJones @Michael Vincent
                                        last edited by Feb 17, 2022, 8:37 PM

                                        @michael-vincent said in Autocomplete Items Order Issue:

                                        alas …

                                        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 (0-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
                                        

                                        The shorter print_r should 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_r0 before print_r. This is a bug in the current implementation.

                                        744c0861-2f0b-4be1-b58a-714c7e28f382-image.png

                                        <?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.

                                        V 1 Reply Last reply Feb 17, 2022, 9:29 PM Reply Quote 4
                                        • M
                                          Michael Vincent @Michael Vincent
                                          last edited by Feb 17, 2022, 8:40 PM

                                          @michael-vincent said in Autocomplete Items Order Issue:

                                          get an issue and pull request accepted

                                          Done and Done. Well, submitted at least, the accepted part will need to wait a bit.

                                          Cheers.

                                          1 Reply Last reply Reply Quote 4
                                          7 out of 35
                                          • First post
                                            7/35
                                            Last post
                                          The Community of users of the Notepad++ text editor.
                                          Powered by NodeBB | Contributors