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

Commit bb3f8bd

Browse files
committed
Fix completions for indentifiers with dollar sign
Fixes #152
1 parent 206f447 commit bb3f8bd

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

SQLTools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ def on_query_completions(view, prefix, locations):
368368
lineStartToLocation = sublime.Region(lineStartPoint, currentPoint)
369369
try:
370370
lineStr = view.substr(lineStartToLocation)
371-
prefix = re.split('[^`\"\w.]+', lineStr).pop()
371+
prefix = re.split('[^`\"\w.\$]+', lineStr).pop()
372372
except Exception as e:
373373
Log(e)
374374

SQLToolsAPI/Completion.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def _stripPrefix(text, prefix):
3939
return text
4040

4141

42+
# escape $ sign when formatting output
43+
def _escapeDollarSign(ident):
44+
return ident.replace("$", "\$")
45+
46+
4247
class CompletionItem(namedtuple('CompletionItem', ['type', 'ident'])):
4348
"""
4449
Represents a potential or actual completion item.
@@ -149,10 +154,10 @@ def format(self, stripQuotes=False):
149154
part = self.ident.split('.')
150155
if len(part) > 1:
151156
return ("{0}\t({1} {2})".format(part[1], part[0], typeDisplay),
152-
_stripQuotesOnDemand(part[1], stripQuotes))
157+
_stripQuotesOnDemand(_escapeDollarSign(part[1]), stripQuotes))
153158

154159
return ("{0}\t({1})".format(self.ident, typeDisplay),
155-
_stripQuotesOnDemand(self.ident, stripQuotes))
160+
_stripQuotesOnDemand(_escapeDollarSign(self.ident), stripQuotes))
156161

157162

158163
class Completion:

0 commit comments

Comments
 (0)