MCPcopy Index your code
hub / github.com/ipython/ipython / get_completions

Method get_completions

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

Source from the content-addressed store, hash-verified

111 return self.shell.Completer
112
113 def get_completions(self, document, complete_event):
114 if not document.current_line.strip():
115 return
116 # Some bits of our completion system may print stuff (e.g. if a module
117 # is imported). This context manager ensures that doesn't interfere with
118 # the prompt.
119
120 with patch_stdout(), provisionalcompleter():
121 body = document.text
122 cursor_row = document.cursor_position_row
123 cursor_col = document.cursor_position_col
124 cursor_position = document.cursor_position
125 offset = cursor_to_position(body, cursor_row, cursor_col)
126 try:
127 yield from self._get_completions(body, offset, cursor_position, self.ipy_completer)
128 except Exception as e:
129 try:
130 exc_type, exc_value, exc_tb = sys.exc_info()
131 traceback.print_exception(exc_type, exc_value, exc_tb)
132 except AttributeError:
133 print('Unrecoverable Error in completions')
134
135 def _get_completions(self, body, offset, cursor_position, ipyc):
136 """

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