SublimeText / CoffeeScript

Syntax highlighting and checking, commands, shortcuts, snippets, watched compilation and more.
439 stars 64 forks source link

Last character missing in auto-suggest in ST4 #251

Closed taneltm closed 1 month ago

taneltm commented 2 years ago

In CoffeeScript classes, when accessing class members with the @ shorthand, the suggestion is missing the last character.
If I recall correctly, this was working properly in ST3.

image

gtarawneh commented 2 years ago

I'm facing the same issue (with all functions actually, not just class methods).

After a bit of digging into my CoffeeScript.tmLanguage I narrowed it down to this section ...

<dict>
    <key>captures</key>
    <dict>
        <key>2</key>
        <dict>
            <key>name</key>
            <string>entity.name.function.coffee</string>
        </dict>
        <key>3</key>
        <dict>
            <key>name</key>
            <string>entity.name.function.coffee</string>
        </dict>
        <key>4</key>
        <dict>
            <key>name</key>
            <string>variable.parameter.function.coffee</string>
        </dict>
        <key>5</key>
        <dict>
            <key>name</key>
            <string>storage.type.function.coffee</string>
        </dict>
    </dict>
    <key>match</key>
    <string>(?x)
        (\s*)
        (?=[a-zA-Z\$_@])
        (
            [a-zA-Z\$_@](\w|\$|:|\.)*\s*
            (?=[:=]( (\s*.\( ($)) | (\s*\(.*\) )?\s*([=-]&gt;)))
        )
    </string>
    <key>name</key>
    <string>meta.function.coffee</string>
</dict>

I don't know tmLanguage syntax but it looks like the 2nd and 3rd capture groups in the unwieldy regex at the bottom are being assigned the name entity.name.function.coffee which narrowed down my blind fiddling efforts.

Workaround (warning: no clue why or how this works 😅)

I found out that deleting the following part seems to resolve to issue ...

<key>3</key>
<dict>
    <key>name</key>
    <string>entity.name.function.coffee</string>
</dict>

although I'm not sure if it fixes an issue with the syntax file or with ST4 itself (I don't recall facing the issue in ST3, even though I was using the same syntax file).

I can't see any immediate impact in terms of syntax coloring (will post any updates here), and now I get correct autocomplete for function names.

If anyone understands why the edit above works please let me know. 😅