Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REPL: really fix #29347, searching a string not in history #29412

Merged
merged 1 commit into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -623,12 +623,17 @@ function history_search(hist::REPLHistoryProvider, query_buffer::IOBuffer, respo
b = b ≤ ncodeunits(response_str) ? prevind(response_str, b) : b-1
b = min(lastindex(response_str), b) # ensure that b is valid

!skip_current && searchdata == response_str[a:b] && return true

searchfunc1, searchfunc2, searchstart, skipfunc = backwards ?
(findlast, findprev, b, prevind) :
(findfirst, findnext, a, nextind)
skip_current && (searchstart = skipfunc(response_str, searchstart))

if searchdata == response_str[a:b]
if skip_current
searchstart = skipfunc(response_str, searchstart)
else
return true
end
end

# Start searching
# First the current response buffer
Expand Down
10 changes: 10 additions & 0 deletions stdlib/REPL/test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,16 @@ for prompt = ["TestΠ", () -> randstring(rand(1:10))]
@test buffercontents(LineEdit.buffer(s)) == "x ΔxΔ"
@test position(LineEdit.buffer(s)) == 0

LineEdit.edit_clear(s)
LineEdit.enter_search(s, histp, true)
ss = LineEdit.state(s, histp)
write(ss.query_buffer, "Å") # should not be in history
LineEdit.update_display_buffer(ss, ss)
@test buffercontents(ss.response_buffer) == ""
@test position(ss.response_buffer) == 0
LineEdit.history_next_result(s, ss) # should not throw BoundsError
LineEdit.accept_result(s, histp)

# Try entering search mode while in custom repl mode
LineEdit.enter_search(s, custom_histp, true)
end
Expand Down