Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Make way for variable completions #81

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions lib/provider.coffee
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ module.exports =
scopes = request.scopeDescriptor.getScopesArray()
isSass = hasScope(scopes, 'source.sass')

if @isCompletingValue(request)
completions = @getPropertyValueCompletions(request)
else if @isCompletingPseudoSelector(request)
completions = @getPseudoSelectorCompletions(request)
else
if isSass and @isCompletingNameOrTag(request)
completions = @getPropertyNameCompletions(request)
.concat(@getTagCompletions(request))
else if not isSass and @isCompletingName(request)
completions = @getPropertyNameCompletions(request)
if not @isCompletingCustomProperty(request)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be unless

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies! This is my first shot at coffeescript. It's a frightening departure from Javascript 😆

if @isCompletingValue(request)
completions = @getPropertyValueCompletions(request)
else if @isCompletingPseudoSelector(request)
completions = @getPseudoSelectorCompletions(request)
else
if isSass and @isCompletingNameOrTag(request)
completions = @getPropertyNameCompletions(request)
.concat(@getTagCompletions(request))
else if not isSass and @isCompletingName(request)
completions = @getPropertyNameCompletions(request)

if not isSass and @isCompletingTagSelector(request)
tagCompletions = @getTagCompletions(request)
Expand All @@ -55,6 +56,12 @@ module.exports =
{@pseudoSelectors, @properties, @tags} = JSON.parse(content) unless error?
return

isCompletingCustomProperty: ({scopeDescriptor}) ->
scopes = scopeDescriptor.getScopesArray()

(hasScope(scopes, 'variable.css')) or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like these have one extra layer of parentheses that can be removed.

(hasScope(scopes, 'meta.function.variable.css'))

isCompletingValue: ({scopeDescriptor, bufferPosition, prefix, editor}) ->
scopes = scopeDescriptor.getScopesArray()

Expand Down