alienhard / SublimeAllAutocomplete

Extend Sublime autocompletion to find matches in all open files of the current window
917 stars 110 forks source link

Autocomplete for php code works incorrectly in some cases #8

Closed sigsergv closed 11 years ago

sigsergv commented 11 years ago

To reproduce you must change settings parameter word_separators and remove character $ there, like this (in Preferences.sublime-settings):

"word_separators": "./\\()\"'-:,.;<>~!@%^&*|+=[]{}`~?",

After that create new file with the following content:

<?php

$test = 'aaaaa'

and try to auto-complete word $test there, you should fail, word just disappears.

It looks like somethere inside sublimetext character $ treated as something special (incorrect regexp generation maybe) so if returned value from on_query_completions starts with $ it will break the completion.

alienhard commented 11 years ago

Your pull request #9 doesn't seem to fix the problem. Did that do anything in your case?

The API call to extract_completions() returns no matches if the first character of the prefix string is a $. I also tested with a colon and it is the same problem. I tried to re.escape() the prefix but that didn't help.

I suspect that Sublime doesn't respect word_separators when tokenizing the content to match it against prefix in extract_completions(). Hence there's never a match. I'm only speculating but we can't check since we don't have access to the source. There's probably nothing we can do, except for reporting the problem.

sigsergv commented 11 years ago

Did you remove character $ from separators list (word_separators config option)? It's important.The code from pull request #9 has solved “disappearing” issue for me.

alienhard commented 11 years ago

Yes, I removed $. The behavior I see is that when I start typing $te there is no completion. I.e., the autocomplete dialog disappears because the are no matches. Is this the "disappearing issue" or do you experience something different? I'd like to understand and be able to reproduce the problem before adding an extra case.

sigsergv commented 11 years ago

OK, let's try another example:

  1. Close all editor windows and open a new empty one
  2. In that window create new file and put the following text there:
<?php
$token = 444;

don't save

  1. Now enter text $to on line below $token = 444; and press completion key

In my case complete text including $to just disappears as it's just deleted.

alienhard commented 11 years ago

I still can't reproduce. Removed $ from word_separators, then did what you said above. When I start typing $to I don't get an autocompleter dialog.

Does anyone else have this problem?