Sublime Forum

@gwenzek - "All AutoComplete" broken in ST3 dev for C# mode

#1

It seems that ST3 dev has broken the popular package All AutoComplete in a subtle way.

To reproduce, create two clean portable installs (std build 3126 & dev build 3141) and add only Package Control and All AutoComplete. No changes to user settings required.

In both installs, open two files, one of which needs to be C# mode.

In the C# file, add a line with three slashes (used for summary type comments)
/// foobar

In the other file, try to autocomplete ‘foo’ to get ‘foobar’. It works with build 3126 but not with 3141.

Note, normal comments with two slashes do not show this problem.

– wolfie

0 Likes

#2

I have just checked - this problem actually started in dev build 3127, presumably in the extensive C# changes by @gwenzek that went into the dev version straight after build 3126.

0 Likes

#3

Thanks for reporting.
I don’t use this package and don’t how it works.
I don’t have access to my PC right now so this is just my thoughts.
Several things may happen here.

  1. The new C# syntax have scopes following the new guidelines which might have break plugins relying on previous scopes names. Both the symbols and the documentation may have their scope changed.

  2. I’m suprised by your workflow.
    If you type foobar in a comment, it’s not recognized as a symbol by the syntax, so it shouldn’t appear in the regular autocomplete in another file. Do you want every word of your documentation comments to appear in the completion list?

  3. There are a few settings files along side the syntax that define which symbol shows up in the symbol list. I think the information is split in several files so maybe the new version introduced a bug. I remembered struggling with those at some point.

0 Likes

#4

I agree that this problem is likely to be related to syntax scope, but why are ‘///’ syle comments now being treated differently from ‘//’ comments? I think that’s the real question here.

Our work source code is heavily documented which is why I want to be able to autocomplete on far more than just regular code symbols.

0 Likes

#5

The /// receive

comment.block.documentation

while the // receive

comment.line.double-slash

I guess if a plugin was expecting /// to be comment.line it wouldn’t find a match. Anyhow, these changes are The Right Way Forward™ I think.

1 Like

#6

Because the ‘///’ comments support a bit of classic XML documentation tags https://msdn.microsoft.com/en-us/library/aa288481(v=vs.71).aspx

1 Like

#7

It seems to boild down to an implementation detail in the undocumented View.extract_completions API, which AllAutoComplete uses and which for some reason does not include words from /// lines. There doesn’t appear to be a setting controlling this, either.

You can reproduce by pasting the following into a new view with the C# syntax:

/// foobar

// normal foo

and then running view.extract_completions("f") in the console.

2 Likes

#8

it works in Plain Text mode. after further investigation, it looks to me like removing https://github.com/sublimehq/Packages/blob/58e2820ab891cf7448334030a6648644c262a805/C%23/C%23.sublime-syntax#L1934 fixes it

1 Like

#9

@kingkeith - yes, this only seems to affect files in C# mode

OK, so in short does this mean

a) the All AutoComplete package needs updating somehow

or

b) the user needs something in their settings added to auto_complete_selector or auto_complete_triggers or both?

0 Likes

#10

Oh, this might be the infamous tokenization issue that has occured previously. Because each character is scoped individually, ST doesn’t have words in entire tokens, which it uses to determine word boundaries among other things.

Iirc this was relevant for spell checking previously.

2 Likes

#11

good call! changing . to to \w+ works (although it would no longer scope whitespace - maybe use match: '[\w\s]+|.' to get the same functionality as before but with the word tokenization fix - @wolfie you can create a PR to https://github.com/sublimehq/Packages with the fix )

0 Likes

#12

Sorry, I don’t know what ‘PR’ means. Are you saying this can’t be fixed in the next dev build (3142)?

0 Likes

#13

I’m saying if you create a Pull Request (a Git version control system term) and it gets merged before build 3142 is released, your fix will be included in that build.

1 Like

#14

Oh, I see. I’m not a Git user - is that something one of you kind souls could do please?

0 Likes

#15

done

3 Likes

#16

Many thanks!

0 Likes

#17

Interesting, never knew this tokenization issue existed.

I’m probably going too much ahead, but if meta_scope is not actually a meta scope but an entity.name.function for instance, is this tokenization issue present?

0 Likes

#18

I patched my C#/C#.sublime-syntax with @kingkeith’s change and can confirm autocompletion now works as expected. Thanks!

0 Likes