Show More
@@ -427,7 +427,7 b' class TransformerManager:' | |||||
427 |
|
427 | |||
428 | def transform_cell(self, cell: str): |
|
428 | def transform_cell(self, cell: str): | |
429 | if not cell.endswith('\n'): |
|
429 | if not cell.endswith('\n'): | |
430 |
cell += '\n' # Ensure |
|
430 | cell += '\n' # Ensure the cell has a trailing newline | |
431 | lines = cell.splitlines(keepends=True) |
|
431 | lines = cell.splitlines(keepends=True) | |
432 | for transform in self.cleanup_transforms + self.line_transforms: |
|
432 | for transform in self.cleanup_transforms + self.line_transforms: | |
433 | #print(transform, lines) |
|
433 | #print(transform, lines) | |
@@ -454,7 +454,7 b' class TransformerManager:' | |||||
454 | status is not 'incomplete', this is None. |
|
454 | status is not 'incomplete', this is None. | |
455 | """ |
|
455 | """ | |
456 | if not cell.endswith('\n'): |
|
456 | if not cell.endswith('\n'): | |
457 |
cell += '\n' # Ensure |
|
457 | cell += '\n' # Ensure the cell has a trailing newline | |
458 | lines = cell.splitlines(keepends=True) |
|
458 | lines = cell.splitlines(keepends=True) | |
459 | if lines[-1][:-1].endswith('\\'): |
|
459 | if lines[-1][:-1].endswith('\\'): | |
460 | # Explicit backslash continuation |
|
460 | # Explicit backslash continuation |
@@ -298,7 +298,7 b' python-profiler package from non-free.""")' | |||||
298 | list_all=True, posix=False) |
|
298 | list_all=True, posix=False) | |
299 | if cell is not None: |
|
299 | if cell is not None: | |
300 | arg_str += '\n' + cell |
|
300 | arg_str += '\n' + cell | |
301 |
arg_str = self.shell.input_ |
|
301 | arg_str = self.shell.input_transformer_manager.transform_cell(arg_str) | |
302 | return self._run_with_profiler(arg_str, opts, self.shell.user_ns) |
|
302 | return self._run_with_profiler(arg_str, opts, self.shell.user_ns) | |
303 |
|
303 | |||
304 | def _run_with_profiler(self, code, opts, namespace): |
|
304 | def _run_with_profiler(self, code, opts, namespace): | |
@@ -1033,7 +1033,7 b' python-profiler package from non-free.""")' | |||||
1033 | # this code has tight coupling to the inner workings of timeit.Timer, |
|
1033 | # this code has tight coupling to the inner workings of timeit.Timer, | |
1034 | # but is there a better way to achieve that the code stmt has access |
|
1034 | # but is there a better way to achieve that the code stmt has access | |
1035 | # to the shell namespace? |
|
1035 | # to the shell namespace? | |
1036 |
transform = self.shell.input_ |
|
1036 | transform = self.shell.input_transformer_manager.transform_cell | |
1037 |
|
1037 | |||
1038 | if cell is None: |
|
1038 | if cell is None: | |
1039 | # called as line magic |
|
1039 | # called as line magic |
@@ -77,7 +77,7 b' def register_ipython_shortcuts(registry, shell):' | |||||
77 |
|
77 | |||
78 | registry.add_binding(Keys.ControlO, |
|
78 | registry.add_binding(Keys.ControlO, | |
79 | filter=(HasFocus(DEFAULT_BUFFER) |
|
79 | filter=(HasFocus(DEFAULT_BUFFER) | |
80 |
& EmacsInsertMode()))(newline_autoindent_outer(shell.input_ |
|
80 | & EmacsInsertMode()))(newline_autoindent_outer(shell.input_transformer_manager)) | |
81 |
|
81 | |||
82 | registry.add_binding(Keys.F2, |
|
82 | registry.add_binding(Keys.F2, | |
83 | filter=HasFocus(DEFAULT_BUFFER) |
|
83 | filter=HasFocus(DEFAULT_BUFFER) | |
@@ -119,7 +119,7 b' def newline_or_execute_outer(shell):' | |||||
119 | check_text = d.text |
|
119 | check_text = d.text | |
120 | else: |
|
120 | else: | |
121 | check_text = d.text[:d.cursor_position] |
|
121 | check_text = d.text[:d.cursor_position] | |
122 |
status, indent = shell.input_ |
|
122 | status, indent = shell.input_transformer_manager.check_complete(check_text + '\n') | |
123 |
|
123 | |||
124 | if not (d.on_last_line or |
|
124 | if not (d.on_last_line or | |
125 | d.cursor_position_row >= d.line_count - d.empty_line_count_at_the_end() |
|
125 | d.cursor_position_row >= d.line_count - d.empty_line_count_at_the_end() |
@@ -282,7 +282,7 b' IPython configuration::' | |||||
282 | else: # insert a newline with auto-indentation... |
|
282 | else: # insert a newline with auto-indentation... | |
283 |
|
283 | |||
284 | if document.line_count > 1: text = text[:document.cursor_position] |
|
284 | if document.line_count > 1: text = text[:document.cursor_position] | |
285 |
indent = shell.input_ |
|
285 | indent = shell.input_transformer_manager.check_complete(text)[1] or 0 | |
286 | buffer.insert_text('\n' + ' ' * indent) |
|
286 | buffer.insert_text('\n' + ' ' * indent) | |
287 |
|
287 | |||
288 | # if you just wanted a plain newline without any indentation, you |
|
288 | # if you just wanted a plain newline without any indentation, you |
General Comments 0
You need to be logged in to leave comments.
Login now