MCPcopy Create free account
hub / github.com/ipython/ipython / get_completions

Method get_completions

IPython/terminal/ptutils.py:99–119  ·  view source on GitHub ↗
(self, document, complete_event)

Source from the content-addressed store, hash-verified

97 return self.shell.Completer
98
99 def get_completions(self, document, complete_event):
100 if not document.current_line.strip():
101 return
102 # Some bits of our completion system may print stuff (e.g. if a module
103 # is imported). This context manager ensures that doesn't interfere with
104 # the prompt.
105
106 with patch_stdout(), provisionalcompleter():
107 body = document.text
108 cursor_row = document.cursor_position_row
109 cursor_col = document.cursor_position_col
110 cursor_position = document.cursor_position
111 offset = cursor_to_position(body, cursor_row, cursor_col)
112 try:
113 yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
114 except Exception as e:
115 try:
116 exc_type, exc_value, exc_tb = sys.exc_info()
117 traceback.print_exception(exc_type, exc_value, exc_tb)
118 except AttributeError:
119 print('Unrecoverable Error in completions')
120
121 @staticmethod
122 def _get_completions(body, offset, cursor_position, ipyc):

Callers

nothing calls this directly

Calls 3

_get_completionsMethod · 0.95
provisionalcompleterFunction · 0.90
cursor_to_positionFunction · 0.90

Tested by

no test coverage detected