Open kruxigt opened 4 years ago
That's how it works for me:
julia> 1
1
julia> "foo"
"foo"
julia> "foo"
"foo"
julia> "foo"
"foo"
julia> "foo"
"foo"
julia> 1 <PRESSED UP TWICE>
That's how it works for me:
julia> 1 1 julia> "foo" "foo" julia> "foo" "foo" julia> "foo" "foo" julia> "foo" "foo" julia> 1 <PRESSED UP TWICE>
That is interesting. That is not how it works for me on any of my installations. All are on Mac OS (different versions of Mac OS- Julia 1.2, 1.3 and 1.4).
Tried on Mac and get the same behavior as in my previous post.
Edit: You are correct. I will now update the initial post to reflect the real problem. Sorry and thanks!
I will now update the initial post to reflect the real problem.
That makes it pretty confusing to read this and understand what is going on. Would be clearer to just post here below what you've figured out.
I will now update the initial post to reflect the real problem.
That makes it pretty confusing to read this and understand what is going on. Would be clearer to just post here below what you've figured out.
I hope my update in the initial post makes this thread clear enough :)
I don't understand how this is different than the original issue.
I don't understand how this is different than the original issue.
I will try to clarify! When going through the history in the REPL with the up-arrow, a command will never appear more than once in a row even though previously entered several times in a row. However, when going through the history using a prefix and then the up arrow, the same command may occur several times in a row. I think the history never saves a command twice in a row (see https://github.com/JuliaLang/julia/pull/26174/files maybe), but with the use of a prefix the same command might appear several times in a row. I guess this needs to be checked when the list of commands matching the prefix is created.
Ok, that's interesting. I've lost track of how this is implemented, but I would think that we would simply not save repeated entries in the history list in the first place, in which case this behavior would not happen, but perhaps I'm incorrect about how this is implemented these days.
Ah, I can reproduce but only when the original commands were not immediately sequential:
julia> a = 1
1
julia> b = 2
2
julia> a = 1
1
julia> b = 3
3
julia> a = 1
1
julia> b = 4
4
julia> a# now up will repeatedly visit a = 1 multiple times
I'm not entirely convinced this is a bad behavior. In fact, I use this behavior! There are times where I'll have a sequence of commands like:
using Foo
foo()
bar()
baz()
Sometimes, during interactive development, I'll get an error upon foo()
. I'll digress, do a bunch of other things, and then want to go back to my original sequence.
using Foo
foo() # ERRORED
debug()
debug()
debug()
I actually expect to do u
↑↑ to jump past my most recent (broken/debug) session and get into my "correct" sequence. Then subsequent ↓s walk through the foo()
// bar()
// baz()
sequence.
I agree that it can be useful that the value is saved several times in history! But I think that the prefix should still just give you the same command once in a row. I.e. the fix should be applied where the list of historical commands is created when the user has specified a prefix. Something like removing all but one of the entries when exactly the same command appears more than once in a row maybe? (The actual implementation is still above my pay grade so to speak)
I actually expect to do
u
↑↑ to jump past my most recent (broken/debug) session and get into my "correct" sequence. Then subsequent ↓s walk through thefoo()
//bar()
//baz()
sequence.
Ah! I see! Good point! I rarely use that tactic, but I can see that there is a need to get to the right entry there.
This seems to work for me now; I only get one instance of repeated inputs with prefix search.
First, I'm sorry if this is trivially stupid or otherwise inappropriate. First timer! Edit: Previously I stated the problem erroneously. Below is a correct restatement.
If I have two commands X and Y which both start with the letter a.
The command X is first entered in the REPL and then command Y is entered 10 times in a row and then some other commands are entered.
A convenient way to reenter command X and Y is then to enter the letter a and push the up arrow. However, to get to command X this way I need to press the up arrow 11 times (just repeating Y 10 times). It would be convenient to be able to get to X in just two presses of the up arrow instead.