Skip to content

Commit 594414d

Browse files
committed
Edit history with cursor at the last line
1 parent 420394a commit 594414d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pythonrc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,11 +661,13 @@ def process_edit_cmd(self, arg=""):
661661
return self.writeline(e)
662662
else:
663663
# - make a list of all lines in history, commenting any non-blank lines.
664-
history = self.session_history or open(config.HISTFILE)
664+
if not (history := self.session_history):
665+
history = open(config.HISTFILE).readlines()
665666
filename = self._mktemp_buffer(
666667
f"# {line}" if line.strip() else ""
667668
for line in (line.strip("\n") for line in history)
668669
)
670+
line_num_opt = config.LINE_NUM_OPT.format(line_no=len(history))
669671

670672
# - shell out to the editor
671673
rc = os.system(f"{config.EDITOR} {line_num_opt} {filename}")

0 commit comments

Comments
 (0)