Skip to content

Commit

Permalink
Merge pull request #10519 from JuliaLang/brj/keymap-catch-errors
Browse files Browse the repository at this point in the history
Don't kill the REPL due to keymap errors.
  • Loading branch information
Keno committed Mar 14, 2015
2 parents 5b4906a + 311fe6f commit 8cb0c50
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions base/LineEdit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,6 @@ function postprocess!(dict::Dict)
# needs to be done first for every branch
if haskey(dict, '\0')
add_specialisations(dict, dict, 1)
else
dict['\0'] = (args...)->error("Unrecognized input")
end
for (k,v) in dict
k == '\0' && continue
Expand Down Expand Up @@ -1573,7 +1571,17 @@ function prompt!(term, prompt, s = init_state(term, prompt))
activate(prompt, s, term)
while true
map = keymap(s, prompt)
state = match_input(map, s)(s, keymap_data(s, prompt))
fcn = match_input(map, s)
# errors in keymaps shouldn't cause the REPL to fail, so wrap in a
# try/catch block
local state
try
state = fcn(s, keymap_data(s, prompt))
catch e
warn("Caught an exception in the keymap:")
warn(e)
state = :done
end
if state == :abort
stop_reading(term)
return buffer(s), false, false
Expand Down

0 comments on commit 8cb0c50

Please sign in to comment.