Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit f0719b8

Browse files
committed
support "$" prefix for autocompletions
1 parent 0b7679c commit f0719b8

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

lib/provider.coffee

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ module.exports =
8585

8686
getJavascriptCompletions: ({ prefix, editor, bufferPosition }) ->
8787
completions = []
88+
prefix = @getPrefix(editor, bufferPosition)
8889
for idx, tag of @completions.javascript
89-
completions.push({ text: tag, type: 'angularjs' })
90+
completions.push({ text: tag, type: 'angularjs', replacementPrefix: prefix })
9091
completions
9192

9293
getPreviousAttribute: (editor, bufferPosition) ->
@@ -100,5 +101,15 @@ module.exports =
100101

101102
attributePattern.exec(editor.getTextInRange([[bufferPosition.row, 0], [bufferPosition.row, quoteIndex]]))?[1]
102103

104+
getPrefix: (editor, bufferPosition) ->
105+
# Whatever your prefix regex might be
106+
regex = /\$?[\w0-9_-]+$/
107+
108+
# Get the text for the line up to the triggered buffer position
109+
line = editor.getTextInRange([[bufferPosition.row, 0], bufferPosition])
110+
111+
# Match the regex to the line, and return the match
112+
line.match(regex)?[0] or ''
113+
103114
firstCharsEqual = (str1, str2) ->
104115
str1[0].toLowerCase() is str2[0].toLowerCase()

0 commit comments

Comments
 (0)