justinmahar / SublimeCSAutocompletePlus

CoffeeScript autocompletions and more!
172 stars 12 forks source link

The autocomplete window shows and then disappears immediately #35

Open simonexmachina opened 11 years ago

simonexmachina commented 11 years ago

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.

justinmahar commented 11 years ago

Is this still an issue for you?

simonexmachina commented 11 years ago

Yes I'm afraid it is.

mlutz commented 11 years ago

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.

justinmahar commented 11 years ago

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 commented 11 years ago

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

simonexmachina commented 11 years ago

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.

justinmahar commented 11 years ago

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.
simonexmachina commented 11 years ago

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

jscheel commented 11 years ago

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. 
m-ender commented 11 years ago

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. ;)