First, please consider the following snippet:
<snippet>
<content><![CDATA[
/* this is a test */
]]></content>
<tabTrigger>test</tabTrigger>
<scope>source.css meta.property-list.css</scope>
</snippet>
This will expands as expected at this cursor position (| marks the cursor):
body {
|
}
Now, consider the following completions file:
{
"completions": [
{
"contents": "/* this is a test */",
"trigger": "test"
}
],
"scope": "source.css meta.property-list.css"
}
I would expect this to expand at the same cursor position, but it does not work at all. The same completion using source.css will expand only outside a CSS selector.
Seems like it deliberately ignores buffer completions, but sublime-completions files shouldn't be disabled as that only happens with sublime.INHIBIT_EXPLICIT_COMPLETIONS.
Probably it is the same underlying issue as this: https://github.com/SublimeTextIssues/Core/issues/1061 - which we can prove by changing the css_completions.py file:
--- css_completions.py
+++ css_completions.py (without special chars)
@@ -476,12 +476,8 @@
return None
else:
- add_colon = not view.match_selector(loc, prop_name_scope)
-
for prop in self.props:
- if add_colon:
- l.append((prop, prop + ": "))
- else:
+ if '-' not in prop and '|' not in prop:
l.append((prop, prop))
return (l, sublime.INHIBIT_WORD_COMPLETIONS)
and lo and behold, the test completion starts working again inside the meta.property-list.css scope, at the expense of any CSS properties with a hyphen in them 馃槈 - tradeoffs... 馃槅
Actually, it seems like it is enough to prevent | being seen as a valid property name, and this solves everything - colons and hyphens don't cause problems here:
--- Packages\CSS\css_completions.py
+++ Packages\CSS\css_completions.py
@@ -416,7 +416,7 @@
# Append values that are allowed for all properties
allowed_values += ['all', 'inherit', 'initial', 'unset']
- for name in names.split():
+ for name in names.split(' | '):
props[name] = sorted(allowed_values)
return props
Actually, it seems like it is enough to prevent | being seen as a valid property name
Not sure what this means. I used | in my example above to mark the cursor position.
I realise that, I'm talking about e.g. https://github.com/sublimehq/Packages/blob/69549082dfb4d958f61f819bd8285af1aed5ed86/CSS/css_completions.py#L139
Most helpful comment
Seems like it deliberately ignores buffer completions, but
sublime-completionsfiles shouldn't be disabled as that only happens with sublime.INHIBIT_EXPLICIT_COMPLETIONS.Probably it is the same underlying issue as this: https://github.com/SublimeTextIssues/Core/issues/1061 - which we can prove by changing the
css_completions.pyfile:and lo and behold, the
testcompletion starts working again inside themeta.property-list.cssscope, at the expense of any CSS properties with a hyphen in them 馃槈 - tradeoffs... 馃槅