sublime_text icon indicating copy to clipboard operation
sublime_text copied to clipboard

Autocomplete suggestions not matched correctly in 4134

Open rchl opened this issue 3 years ago • 5 comments

Description of the bug

For example, typing "$v" doesn't automatically select the "$var" completion but prefers "var_dump".

Steps to reproduce

  1. Add a plugin:
    import sublime
    import sublime_plugin
    from sublime import INHIBIT_WORD_COMPLETIONS, INHIBIT_EXPLICIT_COMPLETIONS
    
    class DollarCompletionListener(sublime_plugin.ViewEventListener):
        def on_query_completions(self, prefix, locations):
            print('on_query_completions, prefix: ', prefix)
            completions = [
                CompletionItem(kind=(3, 'm', 'Method'), trigger='var_dump'),
                CompletionItem(kind=(3, 'm', 'Method'), trigger='$var'),
            ]
            completion_list = CompletionList()
            flags = INHIBIT_EXPLICIT_COMPLETIONS | INHIBIT_WORD_COMPLETIONS
            completion_list.set_completions(completions, flags)
            return completion_list
    
  2. Open new view and set syntax to Javascript (for example)
  3. Type "$v"

Expected behavior

The "$var" completion is selected like in the build 4131:

Screenshot 2022-06-05 at 13 55 16

Actual behavior

The "var_dump" completion is selected. Seems like "$" is not considered when matching completions (it's also not highlighted):

Screenshot 2022-06-05 at 14 04 11

Sublime Text build number

4134

Operating system & version

macOS 12.4

(Linux) Desktop environment and/or window manager

No response

Additional information

Might be related to the fix made for #4855.

Note that in both 4131 and 4134 builds the prefix argument to on_query_completions is an empty string when typing the initial $. Feels a bit weird but regardless of that, it has worked before.

Also note that (even if it didn't happen before either) filtering out the var_dump completely would probably make more sense if $ is used for matching as "var_dump" doesn't contain the $ character.

OpenGL context information

No response

rchl avatar Jun 05 '22 12:06 rchl

I can confirm this is happening for PHP as well.

willrowe avatar Jun 06 '22 13:06 willrowe

~Caused by https://github.com/sublimehq/sublime_text/issues/5444 ?~

jfcherng avatar Jun 07 '22 16:06 jfcherng

Shouln't have any impact on static completions from *.sublime-completions file.

Note: I was able to reproduce this behavior in SAFE MODE with plain PHP completions.

Typing $ followed by v already triggers var_dump, while hitting ctrl+space suggestions.

deathaxe avatar Jun 07 '22 16:06 deathaxe

This is also happening with HTML class expansion. Screen Shot 2022-06-20 at 13 50 47 Screen Shot 2022-06-20 at 13 50 54

willrowe avatar Jun 20 '22 17:06 willrowe

Will the next stable build be released with this regression?

rchl avatar Oct 09 '22 11:10 rchl

As mentioned in https://github.com/sublimehq/sublime_text/issues/5431, this appears to be fixed in 4138.

(have also verified that with my test code)

rchl avatar Oct 21 '22 11:10 rchl

I can confirm that this has been fixed for HTML and seems to be working correctly for PHP too.

willrowe avatar Oct 21 '22 13:10 willrowe

Fixed in Build 4138

hartsublime avatar Dec 14 '22 06:12 hartsublime