Return a function suitable for inserting a indented newline after the cursor. Fancier version of deprecated ``newline_with_copy_margin`` which should compute the correct indentation of the inserted line. That is to say, indent by 4 extra space after a function definition, class def
(inputsplitter)
| 229 | b.cursor_right(count=pos_diff) |
| 230 | |
| 231 | def newline_autoindent_outer(inputsplitter) -> Callable[..., None]: |
| 232 | """ |
| 233 | Return a function suitable for inserting a indented newline after the cursor. |
| 234 | |
| 235 | Fancier version of deprecated ``newline_with_copy_margin`` which should |
| 236 | compute the correct indentation of the inserted line. That is to say, indent |
| 237 | by 4 extra space after a function definition, class definition, context |
| 238 | manager... And dedent by 4 space after ``pass``, ``return``, ``raise ...``. |
| 239 | """ |
| 240 | |
| 241 | def newline_autoindent(event): |
| 242 | """insert a newline after the cursor indented appropriately.""" |
| 243 | b = event.current_buffer |
| 244 | d = b.document |
| 245 | |
| 246 | if b.complete_state: |
| 247 | b.cancel_completion() |
| 248 | text = d.text[:d.cursor_position] + '\n' |
| 249 | _, indent = inputsplitter.check_complete(text) |
| 250 | b.insert_text('\n' + (' ' * (indent or 0)), move_cursor=False) |
| 251 | |
| 252 | return newline_autoindent |
| 253 | |
| 254 | |
| 255 | def open_input_in_editor(event): |
no outgoing calls
no test coverage detected