Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
Merge pull request #156 from mtxr/fix-completions-with-dollar-sign
Browse files Browse the repository at this point in the history
Fix completions for identifiers with dollar sign
  • Loading branch information
tkopets authored Nov 8, 2017
2 parents 206f447 + bb3f8bd commit 32bfce6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion SQLTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def on_query_completions(view, prefix, locations):
lineStartToLocation = sublime.Region(lineStartPoint, currentPoint)
try:
lineStr = view.substr(lineStartToLocation)
prefix = re.split('[^`\"\w.]+', lineStr).pop()
prefix = re.split('[^`\"\w.\$]+', lineStr).pop()
except Exception as e:
Log(e)

Expand Down
9 changes: 7 additions & 2 deletions SQLToolsAPI/Completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def _stripPrefix(text, prefix):
return text


# escape $ sign when formatting output
def _escapeDollarSign(ident):
return ident.replace("$", "\$")


class CompletionItem(namedtuple('CompletionItem', ['type', 'ident'])):
"""
Represents a potential or actual completion item.
Expand Down Expand Up @@ -149,10 +154,10 @@ def format(self, stripQuotes=False):
part = self.ident.split('.')
if len(part) > 1:
return ("{0}\t({1} {2})".format(part[1], part[0], typeDisplay),
_stripQuotesOnDemand(part[1], stripQuotes))
_stripQuotesOnDemand(_escapeDollarSign(part[1]), stripQuotes))

return ("{0}\t({1})".format(self.ident, typeDisplay),
_stripQuotesOnDemand(self.ident, stripQuotes))
_stripQuotesOnDemand(_escapeDollarSign(self.ident), stripQuotes))


class Completion:
Expand Down

0 comments on commit 32bfce6

Please sign in to comment.