8000 fix pager typo and refactor some unused branches (#41) · DinoV/cpython@2c524b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2c524b8

Browse files
tonybaloneyDinoV
authored andcommitted
fix pager typo and refactor some unused branches (python#41)
1 parent 683f5f6 commit 2c524b8

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Lib/_pyrepl/reader.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -441,14 +441,13 @@ def get_arg(self, default: int = 1) -> int:
441441
"""
442442
if self.arg is None:
443443
return default
444-
else:
445-
return self.arg
444+
return self.arg
446445

447446
def get_prompt(self, lineno: int, cursor_on_line: bool) -> str:
448447
"""Return what should be in the left-hand margin for line
449448
'lineno'."""
450449
if self.arg is not None and cursor_on_line:
451-
prompt = "(arg: %s) " % self.arg
450+
prompt = f"(arg: {self.arg}) "
452451
elif self.paste_mode:
453452
prompt = "(paste) "
454453
elif "\n" in self.buffer:
@@ -514,12 +513,12 @@ def pos2xy(self) -> tuple[int, int]:
514513
offset = l - 1 if in_wrapped_line else l # need to remove backslash
515514
if offset >= pos:
516515
break
516+
517+
if p + sum(l2) >= self.console.width:
518+
pos -= l - 1 # -1 cause backslash is not in buffer
517519
else:
518-
if p + sum(l2) >= self.console.width:
519-
pos -= l - 1 # -1 cause backslash is not in buffer
520-
else:
521-
pos -= l + 1 # +1 cause newline is in buffer
522-
y += 1
520+
pos -= l + 1 # +1 cause newline is in buffer
521+
y += 1
523522
return p + sum(l2[:pos]), y
524523

525524
def insert(self, text: str | list[str]) -> None:
@@ -577,7 +576,6 @@ def suspend(self) -> SimpleContextManager:
577576
for arg in ("msg", "ps1", "ps2", "ps3", "ps4", "paste_mode"):
578577
setattr(self, arg, prev_state[arg])
579578
self.prepare()
580-
pass
581579

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

0 commit comments

Comments
 (0)
0