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

Guard against keymap errors during initialization #64

Merged
merged 3 commits into from
Apr 4, 2019
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
4 changes: 0 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ notifications:
install:
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))

# HeaderREPLs isn't registered yet
before_build:
- C:\julia\bin\julia -e "using Pkg; Pkg.add(Pkg.REPLMode.parse_package(\"https://github.com/timholy/HeaderREPLs.jl\"; add_or_develop=true))"

build_script:
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
Expand Down
10 changes: 9 additions & 1 deletion src/Rebugger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ function rebugrepl_init(main_repl, repl_inited)
end

function __init__()
schedule(Task(rebugrepl_init))
# schedule(Task(rebugrepl_init))
task = Task() do
try
rebugrepl_init()
catch exception
@error "Rebugger initialization failed" exception=(exception, catch_backtrace())
end
end
schedule(task)
end

include("precompile.jl")
Expand Down
19 changes: 15 additions & 4 deletions src/ui.jl
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ function HeaderREPLs.setup_prompt(repl::HeaderREPL{InterpretHeader}, hascolor::B
prompt.on_done = HeaderREPLs.respond(repl, julia_prompt) do str
return DummyAST()
end
return prompt, :rebug
return prompt, :interpret
end

function HeaderREPLs.append_keymaps!(keymaps, repl::HeaderREPL{InterpretHeader})
Expand Down Expand Up @@ -496,19 +496,30 @@ function add_keybindings(main_repl; override::Bool=false, kwargs...)
if haskey(keybindings, action)
keybindings[action] = keybinding
end
# PackageCompiler can cause these keys to be added twice (once during compilation and once by __init__),
# so put these in a try/catch (issue #62)
if action == :interpret
LineEdit.add_nested_key!(julia_prompt.keymap_dict, keybinding, modeswitches[action], override=override)
try
LineEdit.add_nested_key!(julia_prompt.keymap_dict, keybinding, modeswitches[action], override=override)
catch
end
else
# We need Any here because "cannot convert REPL.LineEdit.PrefixHistoryPrompt to an object of type REPL.LineEdit.Prompt"
prompts = Any[julia_prompt, rebug_prompt]
if action == :stacktrace push!(prompts, history_prompt) end
for prompt in prompts
if keybinding isa Vector
for kb in keybinding
LineEdit.add_nested_key!(prompt.keymap_dict, kb, modeswitches[action], override=override)
try
LineEdit.add_nested_key!(prompt.keymap_dict, kb, modeswitches[action], override=override)
catch
end
end
else
LineEdit.add_nested_key!(prompt.keymap_dict, keybinding, modeswitches[action], override=override)
try
LineEdit.add_nested_key!(prompt.keymap_dict, keybinding, modeswitches[action], override=override)
catch
end
end
end
end
Expand Down