SublimeCSAutocompletePlus icon indicating copy to clipboard operation
SublimeCSAutocompletePlus copied to clipboard

The autocomplete window shows and then disappears immediately

Open simonexmachina opened this issue 12 years ago • 10 comments

Don't know what other info to provide, but I'm using an up to date Sublime Text 2 on Mac OS 10.8. Let me know what else I can provide to help.

simonexmachina avatar May 01 '13 01:05 simonexmachina

Is this still an issue for you?

justinmahar avatar May 01 '13 14:05 justinmahar

Yes I'm afraid it is.

simonexmachina avatar May 02 '13 01:05 simonexmachina

If you have installed the Package "CoffeeScript" remove this package and everything is working again ;-). I have the autocomplete and the installed the Package and have the same problem like you. After removing the package everything works great again.

mlutz avatar May 15 '13 20:05 mlutz

Interesting. I have CoffeeScript installed, yet autocomplete is working fine. A short while ago, I merged in a pull request that broke autocomplete. This has since been resolved. Autocomplete works best when using CoffeeScript class syntax. I suggest trying to create a simple class called HelloCoffee. In the constructor, define a new string, and try accessing that string's properties. When not using CS classes, autocomplete is "lost" in that it doesn't quite know what the context is. It uses the class syntax as its point of reference, and any "this" will be considered from the class in which it's being used. Hope this helps. Please let me know if it's working for you.

justinmahar avatar May 20 '13 20:05 justinmahar

If you want to give this a shot, just copypasta the following. Then, hit ctrl+space after woot.

class HelloCoffee
    constructor: ->
        woot = "Woot!"
        # After the dot, you should get an autocomplete popup with String's properties (length, charAt, ..., etc).
        woot. 

Let me know what happens (i.e., magical autocomplete popup with the answers to the universe, vs nothing).

justinmahar avatar May 20 '13 20:05 justinmahar

Yes, that does work. I'm using Ember and the way to construct an instance is:

Class = Em.Object.extend foo: -> 'bar'
object = Class.create()

When I type object. the autocomplete window shows and then immediately disappears.

simonexmachina avatar May 21 '13 01:05 simonexmachina

Does something like the following work for you? If so, then autocomplete will work. Otherwise, it's not going to work as the plugin is limited to CS classes. Backbone classes that are extended this way work fine, so it's worth a shot.

class FooClass extends Em.Object
    foo: ->
        'bar'
    baz: ->
        # Autocomplete should show foo, baz, and methods inherited from Object.
        this.

justinmahar avatar May 22 '13 14:05 justinmahar

Yes it will work, but the code won't because Ember's got it's own object model :(

simonexmachina avatar May 22 '13 23:05 simonexmachina

Ok, here is a reproducible text case.

Working

class HelloCoffee
    constructor: ->
        woot = "Woot!"
        # After the dot, you should get an autocomplete popup with String's properties (length, charAt, ..., etc).
        woot. 

Broken

class exports.HelloCoffee
    constructor: ->
        woot = "Woot!"
        # After the dot, you should get an autocomplete popup with String's properties (length, charAt, ..., etc).
        woot. 

jscheel avatar Jul 03 '13 21:07 jscheel

While the above works for me, I have a similar problem when trying to access class properties. If I use

root = global ? window
class root.MyClass

Then I cannot get an auto-completion for @ or this.. If I remove the root. everything works fine.

It seems I could fix it by changing (in coffee_utils.py):

   CLASS_REGEX_ANY = r"class\s+([a-zA-Z0-9_$]+)((\s*$)|[^a-zA-Z0-9_$])"
=> CLASS_REGEX_ANY = r"class\s+([.a-zA-Z0-9_$]+)((\s*$)|[^a-zA-Z0-9_$])"

But I'm not sure whether that breaks anything else, so I'm shy with a pull request. ;)

m-ender avatar Jul 07 '13 11:07 m-ender