Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_package_completions(self, document, complete_event):
text_before = document.current_line_before_cursor
token_match = TOKEN_PATTERN.match(text_before)
library_prefix = LIBRARY_PATTERN.match(text_before)
if token_match and not library_prefix:
token = token_match.group(1)
instring = cursor_in_string(document)
for p in installed_packages():
if p.startswith(token):
comp = p if instring else p + "::"
yield Completion(comp, -len(token))
def get_package_completions(self, document, complete_event):
text_before = document.current_line_before_cursor
token_match = TOKEN_PATTERN.match(text_before)
if not token_match:
return
token = token_match.group(1)
library_prefix = LIBRARY_PATTERN.match(text_before)
instring = cursor_in_string(document)
for p in installed_packages():
if p.startswith(token):
comp = p if instring or library_prefix else p + "::"
yield Completion(comp, -len(token))
def string_scope():
app = get_app()
return cursor_in_string(app.current_buffer.document)