Skip to content

Commit 86b050f

Browse files
authored
fix pager typo and refactor some unused branches (python#41)
1 parent 1a7e7b1 commit 86b050f

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

Lib/_pyrepl/pager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_pager() -> Pager:
3535
if os.environ.get('TERM') in ('dumb', 'emacs'):
3636
return plain_pager
3737
if sys.platform == 'win32':
38-
return lambda text, title='': tempfilepager(plain(text), 'more <')
38+
return lambda text, title='': tempfile_pager(plain(text), 'more <')
3939
if hasattr(os, 'system') and os.system('(less) 2>/dev/null') == 0:
4040
return lambda text, title='': pipe_pager(text, 'less', title)
4141

Lib/_pyrepl/reader.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -407,14 +407,13 @@ def get_arg(self, default: int = 1) -> int:
407407
"""
408408
if self.arg is None:
409409
return default
410-
else:
411-
return self.arg
410+
return self.arg
412411

413412
def get_prompt(self, lineno: int, cursor_on_line: bool) -> str:
414413
"""Return what should be in the left-hand margin for line
415414
`lineno'."""
416415
if self.arg is not None and cursor_on_line:
417-
prompt = "(arg: %s) " % self.arg
416+
prompt = f"(arg: {self.arg}) "
418417
elif self.paste_mode:
419418
prompt = "(paste) "
420419
elif "\n" in self.buffer:
@@ -480,12 +479,12 @@ def pos2xy(self) -> tuple[int, int]:
480479
offset = l - 1 if in_wrapped_line else l # need to remove backslash
481480
if offset >= pos:
482481
break
482+
483+
if p + sum(l2) >= self.console.width:
484+
pos -= l - 1 # -1 cause backslash is not in buffer
483485
else:
484-
if p + sum(l2) >= self.console.width:
485-
pos -= l - 1 # -1 cause backslash is not in buffer
486-
else:
487-
pos -= l + 1 # +1 cause newline is in buffer
488-
y += 1
486+
pos -= l + 1 # +1 cause newline is in buffer
487+
y += 1
489488
return p + sum(l2[:pos]), y
490489

491490
def insert(self, text: str | list[str]) -> None:
@@ -543,7 +542,6 @@ def suspend(self) -> SimpleContextManager:
543542
for arg in ("msg", "ps1", "ps2", "ps3", "ps4", "paste_mode"):
544543
setattr(self, arg, prev_state[arg])
545544
self.prepare()
546-
pass
547545

548546
def finish(self) -> None:
549547
"""Called when a command signals that we're finished."""

0 commit comments

Comments
 (0)