Skip to content

Commit

Permalink
fix pager typo and refactor some unused branches (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonybaloney authored and DinoV committed May 24, 2024
1 parent 683f5f6 commit 2c524b8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions Lib/_pyrepl/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,13 @@ def get_arg(self, default: int = 1) -> int:
"""
if self.arg is None:
return default
else:
return self.arg
return self.arg

def get_prompt(self, lineno: int, cursor_on_line: bool) -> str:
"""Return what should be in the left-hand margin for line
'lineno'."""
if self.arg is not None and cursor_on_line:
prompt = "(arg: %s) " % self.arg
prompt = f"(arg: {self.arg}) "
elif self.paste_mode:
prompt = "(paste) "
elif "\n" in self.buffer:
Expand Down Expand Up @@ -514,12 +513,12 @@ def pos2xy(self) -> tuple[int, int]:
offset = l - 1 if in_wrapped_line else l # need to remove backslash
if offset >= pos:
break

if p + sum(l2) >= self.console.width:
pos -= l - 1 # -1 cause backslash is not in buffer
else:
if p + sum(l2) >= self.console.width:
pos -= l - 1 # -1 cause backslash is not in buffer
else:
pos -= l + 1 # +1 cause newline is in buffer
y += 1
pos -= l + 1 # +1 cause newline is in buffer
y += 1
return p + sum(l2[:pos]), y

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

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

0 comments on commit 2c524b8

Please sign in to comment.