diff --git a/SQLTools.py b/SQLTools.py index f6964dc..45bf772 100644 --- a/SQLTools.py +++ b/SQLTools.py @@ -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) diff --git a/SQLToolsAPI/Completion.py b/SQLToolsAPI/Completion.py index 187be51..0a1b43d 100644 --- a/SQLToolsAPI/Completion.py +++ b/SQLToolsAPI/Completion.py @@ -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. @@ -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: