Skip to content

Commit 5e0e2f0

Browse files
committed
fix for issue #45
1 parent 80727ef commit 5e0e2f0

File tree

1 file changed

+44
-41
lines changed

1 file changed

+44
-41
lines changed

sas_kernel/kernel.py

Lines changed: 44 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -243,50 +243,53 @@ def get_completions(self, info):
243243
else:
244244
relstart = info['start']
245245
seg = info['line'][:relstart]
246-
if relstart > 0 and re.match('(?i)proc', seg.rsplit(None, 1)[-1]):
246+
try:
247+
if relstart > 0 and re.match('(?i)proc', seg.rsplit(None, 1)[-1]):
248+
potentials = re.findall(
249+
'(?i)^' + info['obj'] + '.*', self.strproclist, re.MULTILINE)
250+
return potentials
251+
except:
252+
pass
253+
254+
lastproc = info['code'].lower()[:info['help_pos']].rfind('proc')
255+
lastdata = info['code'].lower()[:info['help_pos']].rfind('data ')
256+
proc = False
257+
data = False
258+
if lastproc + lastdata == -2:
259+
pass
260+
else:
261+
if lastproc > lastdata:
262+
proc = True
263+
else:
264+
data = True
265+
266+
if proc:
267+
# we are not in data section should see if proc option or statement
268+
lastsemi = info['code'].rfind(';')
269+
mykey = 's'
270+
if lastproc > lastsemi:
271+
mykey = 'p'
272+
procer = re.search(r'(?i)proc\s\w+', info['code'][lastproc:])
273+
method = procer.group(0).split(' ')[-1].upper() + mykey
274+
mylist = self.compglo[method][0]
275+
potentials = re.findall(
276+
'(?i)' + info['obj'] + '.+', '\n'.join(str(x) for x in mylist), re.MULTILINE)
277+
return potentials
278+
elif data:
279+
# we are in statements (probably if there is no data)
280+
# assuming we are in the middle of the code
281+
282+
lastsemi = info['code'].rfind(';')
283+
mykey = 's'
284+
if lastproc > lastsemi:
285+
mykey = 'p'
286+
mylist = self.compglo['DATA' + mykey][0]
247287
potentials = re.findall(
248-
'(?i)^' + info['obj'] + '.*', self.strproclist, re.MULTILINE)
288+
'(?i)^' + info['obj'] + '.*', '\n'.join(str(x) for x in mylist), re.MULTILINE)
249289
return potentials
250290
else:
251-
lastproc = info['code'].lower()[:info['help_pos']].rfind('proc')
252-
lastdata = info['code'].lower()[:info['help_pos']].rfind('data ')
253-
proc = False
254-
data = False
255-
if lastproc + lastdata == -2:
256-
pass
257-
else:
258-
if lastproc > lastdata:
259-
proc = True
260-
else:
261-
data = True
262-
263-
if proc:
264-
# we are not in data section should see if proc option or statement
265-
lastsemi = info['code'].rfind(';')
266-
mykey = 's'
267-
if lastproc > lastsemi:
268-
mykey = 'p'
269-
procer = re.search(r'(?i)proc\s\w+', info['code'][lastproc:])
270-
method = procer.group(0).split(' ')[-1].upper() + mykey
271-
mylist = self.compglo[method][0]
272-
potentials = re.findall(
273-
'(?i)' + info['obj'] + '.+', '\n'.join(str(x) for x in mylist), re.MULTILINE)
274-
return potentials
275-
elif data:
276-
# we are in statements (probably if there is no data)
277-
# assuming we are in the middle of the code
278-
279-
lastsemi = info['code'].rfind(';')
280-
mykey = 's'
281-
if lastproc > lastsemi:
282-
mykey = 'p'
283-
mylist = self.compglo['DATA' + mykey][0]
284-
potentials = re.findall(
285-
'(?i)^' + info['obj'] + '.*', '\n'.join(str(x) for x in mylist), re.MULTILINE)
286-
return potentials
287-
else:
288-
potentials = ['']
289-
return potentials
291+
potentials = ['']
292+
return potentials
290293

291294
@staticmethod
292295
def _get_right_list(s):

0 commit comments

Comments
 (0)