FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-111201: fix auto-indent in pyrepl for muliple pound comments · wiggin15/cpython@dbec792 · GitHub

Repository navigation

Commit dbec792

Browse files
committed
pythongh-111201: fix auto-indent in pyrepl for muliple pound comments
1 parent 4c31791 commit dbec792

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎Lib/_pyrepl/readline.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def _should_auto_indent(buffer: list[str], pos: int) -> bool:
249249
while pos > 0:
250250
pos -= 1
251251
if last_char is None:
252-
if buffer[pos] not in " \t\n": # ignore whitespaces
252+
if buffer[pos] not in " \t\n#": # ignore whitespaces and comments
253253
last_char = buffer[pos]
254254
else:
255255
# even if we found a non-whitespace character before

‎Lib/test/test_pyrepl/test_pyrepl.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,24 @@ def test_auto_indent_with_comment(self):
465465
output = multiline_input(reader)
466466
self.assertEqual(output, output_code)
467467

468+
def test_auto_indent_with_multicomment(self):
469+
# fmt: off
470+
events = code_to_events(
471+
"def f(): ## foo\n"
472+
"pass\n\n"
473+
)
474+
475+
output_code = (
476+
"def f(): ## foo\n"
477+
" pass\n"
478+
" "
479+
)
480+
# fmt: on
481+
482+
reader = self.prepare_reader(events)
483+
output = multiline_input(reader)
484+
self.assertEqual(output, output_code)
485+
468486
def test_auto_indent_ignore_comments(self):
469487
# fmt: off
470488
events = code_to_events(

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL