Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else:
print("unexpected error was caught.")
print("please report to https://github.com/randy3k/radian for such error.")
print(e)
import traceback
traceback.print_exc()
import os
os._exit(1)
current_mode = session.current_mode
if current_mode.on_post_accept:
result = current_mode.on_post_accept(session)
if result is not None:
return result
if settings.insert_new_line and current_mode.insert_new_line:
app.output.write_raw("\n")
text = None
return text
activated = False
for name in reversed(session.modes):
mode = session.modes[name]
if mode.activator and mode.activator(session):
session.activate_mode(name)
activated = True
break
if not activated:
session.activate_mode("unknown")
current_mode = session.current_mode
if interrupted[0]:
interrupted[0] = False
elif not TERMINAL_CURSOR_AT_BEGINNING[0] or \
(settings.insert_new_line and current_mode.insert_new_line):
app.output.write_raw("\n")
text = None
while text is None:
try:
text = session.prompt(add_history=add_history)
except KeyboardInterrupt:
interrupted[0] = True
raise
except Exception as e:
if isinstance(e, EOFError):
# todo: confirmation in "r" mode
return None
with suppress_stderr():
try:
token = rcompletion.assign_line_buffer(text_before)
# do not timeout package::func
if "::" in token or completion_requested:
timeout = 0
else:
timeout = self.timeout
rcompletion.complete_token(timeout)
completions = rcompletion.retrieve_completions()
except Exception:
completions = []
for c in completions:
if c.startswith(token) and c != token:
if c.endswith("=") and settings.completion_adding_spaces_around_equals:
c = c[:-1] + " = "
if c.endswith("::"):
# let get_package_completions handles it
continue
yield Completion(c, -len(token))
def newline(event, chars=["{", "[", "("]):
should_indent = event.current_buffer.document.char_before_cursor in chars
copy_margin = not in_paste_mode() and settings.auto_indentation
event.current_buffer.newline(copy_margin=copy_margin)
if should_indent and settings.auto_indentation:
tab_size = settings.tab_size
event.current_buffer.insert_text(" " * tab_size)
def auto_indentation():
return settings.auto_indentation