Skip to content

Commit

Permalink
Merge pull request #37 from pindash/patch-1
Browse files Browse the repository at this point in the history
fixes #34 Namespace Code Completion Bug
  • Loading branch information
komsit37 authored Sep 1, 2022
2 parents cbe1f9d + c8cd5c0 commit 761cc7b
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions q_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ def on_query_completions(self, view, prefix, locations):
return []
compl = view.settings().get('q_compl')
#print(compl)
return compl or []
# sublime uses '.'to seperate words so dot will be replaced in autocomplete
# we can work around this by guessing what the user wants, if the '.' is missing suggest dot completions
cw = view.substr(sublime.Region(
view.find_by_class(locations[0], False, 1, " "),locations[0]))
nscompl = view.settings().get(
'q_nscompl') if cw[0] == "." else view.settings().get('q_nscomplwdot')
return compl+nscompl or []

#put this class in this file because it updates view settings 'q_compl'
class QUpdateCompletionsCommand(q_send.QSendRawCommand):
Expand Down Expand Up @@ -57,18 +63,22 @@ def send(self, con, s):
compl.extend(self.makeCompletions(res[b'f'], 'Function'))
compl.extend(self.makeCompletions(res[b'q'], 'q'))
compl.extend(self.makeCompletions(['select', 'from', 'update', 'delete'], 'q'))

nscompl=[]
nscomplwdot=[]
ns = res[b'ns']
for x in ns.iteritems():
n = x[0].decode('utf-8')
compl.append((n + '\tNamespace', n[1:]))
nscompl.append((n[1:] + '\tNamespace', n[1:]))
nscomplwdot.append((n + '\tNamespace', n))
for c in x[1]:
c = c.decode('utf-8')
#print(c)
f = n + '.' + c
compl.append((f + '\t' + n, f[1:]))

nscompl.append((f[1:] + '\t' + n, f[1:]))
nscomplwdot.append((f + '\t' + n, f))
self.view.settings().set('q_compl', compl)
self.view.settings().set('q_nscompl', nscompl)
self.view.settings().set('q_nscomplwdot', nscomplwdot)
finally:
q.close()

Expand Down

0 comments on commit 761cc7b

Please sign in to comment.