Open ahundt opened 7 years ago
Hi @ahundt, from https://github.com/jonathanslenders/python-prompt-toolkit/pull/534#issuecomment-322538767, I can see that the idea of the change should go in, which is cool :+1:
I am not sure about your changes in https://github.com/ahundt/python-prompt-toolkit/commit/e62d188ac311695192b3fb1495f8e5d4ddd619df. It seems like the purpose of enable_history_search
is to enable the functionality, not to configure the functionality. What do you think about adding a different optional argument, perhaps a callable (which might reduce having to specify explicitly all the keywords) that configures the searching? The default would then be the existing functionality.
This seems like a better API to me. Just some thoughts from a passing issue gardener :)
I'll defer to you on design. I think python prompt toolkit 2 has a completely different design so this PR may no longer be useful.
Please note that this is a code base I'm not familiar with, so I just tried to implement it with the fewest possible modifications.
@jonathanslenders Is this now possible to do in 2.0.x? If so, could you explain how & then this issue can likely be closed.
I believe the current history search matches from the start of the string. Could it be updated with an option for matching anywhere in the string?
The
enable_history_search
could perhaps be updated where the currentTrue
andFalse
settings do as they have done, but now there are additional options forenable_history_search=
:'starts-with'
(same as currentenable_history_search=True
setting)'contains'
(matches anywhere in the string).I may not understand the classes right, but I'm looking at making the change... my thoughts are below:
The actual string search part at each line is hopefully easy, assuming basic python strings are actually used internally: