@@ -173,10 +173,12 @@ def first(self):
173173 self .index = len (self .entries )
174174 return self .entries [- self .index ]
175175
176- def back (self , match = True ):
176+ def back (self , start = True , search = False ):
177177 """Move one step back in the history."""
178178 if not self .is_at_end :
179- if match :
179+ if search :
180+ self .index += self .find_partial_match_backward (self .saved_line )
181+ elif match :
180182 self .index += self .find_match_backward (self .saved_line )
181183 else :
182184 self .index += 1
@@ -189,10 +191,20 @@ def find_match_backward(self, search_term):
189191 return idx + 1
190192 return 0
191193
192- def forward (self , match = True ):
194+ def find_partial_match_backward (self , search_term ):
195+ filtered_list_len = len (self .entries ) - self .index
196+ for idx , val in enumerate (reversed (self .entries [:filtered_list_len ])):
197+ if search_term in val :
198+ return idx + 1
199+ return 0
200+
201+
202+ def forward (self , start = True , search = False ):
193203 """Move one step forward in the history."""
194204 if self .index > 1 :
195- if match :
205+ if search :
206+ self .index -= self .find_partial_match_forward (self .saved_line )
207+ elif match :
196208 self .index -= self .find_match_forward (self .saved_line )
197209 else :
198210 self .index -= 1
@@ -208,6 +220,15 @@ def find_match_forward(self, search_term):
208220 return idx + 1
209221 return self .index
210222
223+ def find_partial_match_forward (self , search_term ):
224+ filtered_list_len = len (self .entries ) - self .index + 1
225+ for idx , val in enumerate (self .entries [filtered_list_len :]):
226+ if search_term in val :
227+ return idx + 1
228+ return self .index
229+
230+
231+
211232 def last (self ):
212233 """Move forward to the end of the history."""
213234 if not self .is_at_start :
0 commit comments