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

a few more 0.7 updates #672

Merged
merged 6 commits into from
Jul 7, 2018
Merged
Show file tree
Hide file tree
Changes from 5 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: 7 additions & 4 deletions src/IJulia.jl
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function clear_history(indices)
end

# since a range could be huge, intersect it with 1:n first
clear_history(r::AbstractRange{T}) where {T<:Integer} =
clear_history(r::AbstractRange{<:Integer}) =
invoke(clear_history, Tuple{Any}, intersect(r, 1:n))

function clear_history()
Expand Down Expand Up @@ -273,7 +273,8 @@ push_postexecute_hook(f::Function) = push!(postexecute_hooks, f)
Remove a function `f()` from the list of functions to
execute after executing any notebook cell.
"""
pop_postexecute_hook(f::Function) = splice!(postexecute_hooks, findfirst(equalto(f), postexecute_hooks))
pop_postexecute_hook(f::Function) =
splice!(postexecute_hooks, findlast(isequal(f), postexecute_hooks))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compat.?


const preexecute_hooks = Function[]
"""
Expand All @@ -289,7 +290,8 @@ push_preexecute_hook(f::Function) = push!(preexecute_hooks, f)
Remove a function `f()` from the list of functions to
execute before executing any notebook cell.
"""
pop_preexecute_hook(f::Function) = splice!(preexecute_hooks, findfirst(equalto(f), preexecute_hooks))
pop_preexecute_hook(f::Function) =
splice!(preexecute_hooks, findlast(isequal(f), preexecute_hooks))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compat.?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn’t need it. If f isn’t found, whether findlast returns 0 or nothing splice! will throw.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(But I guess it wouldn't hurt to make sure it throws the same exception on 0.6 and 0.7.)


# similar, but called after an error (e.g. to reset plotting state)
const posterror_hooks = Function[]
Expand All @@ -306,7 +308,8 @@ push_posterror_hook(f::Function) = push!(posterror_hooks, f)
Remove a function `f()` from the list of functions to
execute after an error occurs when a notebook cell is evaluated.
"""
pop_posterror_hook(f::Function) = splice!(posterror_hooks, findfirst(equalto(f), posterror_hooks))
pop_posterror_hook(f::Function) =
splice!(posterror_hooks, findlast(isequal(f), posterror_hooks))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compat.?


#######################################################################

Expand Down
12 changes: 5 additions & 7 deletions src/execute_request.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function display_dict(x)
data = Dict{String,Any}("text/plain" => limitstringmime(text_plain, x))
if showable(application_vnd_vegalite_v2, x)
data[string(application_vnd_vegalite_v2)] = JSON.JSONText(limitstringmime(application_vnd_vegalite_v2, x))
elseif mimewritable(application_vnd_vega_v3, x) # don't send vega if we have vega-lite
elseif showable(application_vnd_vega_v3, x) # don't send vega if we have vega-lite
data[string(application_vnd_vega_v3)] = JSON.JSONText(limitstringmime(application_vnd_vega_v3, x))
end
if showable(application_vnd_dataresource, x)
Expand Down Expand Up @@ -59,10 +59,8 @@ const displayqueue = Any[]

# remove x from the display queue
function undisplay(x)
i = findfirst(isequal(x), displayqueue)
if i !== nothing && i > 0
splice!(displayqueue, i)
end
i = Compat.findfirst(isequal(x), displayqueue)
i !== nothing && splice!(displayqueue, i)
return x
end

Expand All @@ -74,8 +72,8 @@ end

function show_bt(io::IO, top_func::Symbol, t, set)
# follow PR #17570 code in removing top_func from backtrace
eval_ind = findlast(addr->ip_matches_func(addr, top_func), t)
eval_ind !== nothing && eval_ind != 0 && (t = t[1:eval_ind-1])
eval_ind = Compat.findlast(addr->ip_matches_func(addr, top_func), t)
eval_ind !== nothing && (t = t[1:eval_ind-1])
Base.show_backtrace(io, t)
end

Expand Down