plug-ins: do not cycle through Python Console history.

When you want to get back to the latest command, it is very confusing
when it starts cycling from the oldest history command!
This commit is contained in:
Jehan 2024-12-17 23:15:53 +01:00
parent 3284e9a487
commit 9588132849

View file

@ -115,10 +115,16 @@ class _ReadLine(object):
elif self.ptr in self.edited:
del self.edited[self.ptr]
self.ptr = self.ptr + dir
if self.ptr >= len(self.items):
self.ptr = 0
elif self.ptr < 0:
# Do not cycle. It's confusing.
if (self.ptr == 0 and dir > 0) or self.ptr + dir >= len(self.items):
# Position 0 is a bit weird. It's the last position, not
# the first!
self.ptr = 0
elif self.ptr > 0 and dir < 0 and self.ptr + dir < 1:
self.ptr = 1
else:
self.ptr = self.ptr + dir
if self.ptr < 0:
self.ptr = len(self.items) - 1
try: