Skip to content

Fix edit_insert MethodError in debug-mode keymap fallback on Julia 1.12 - #421

Open
mattlie82 wants to merge 1 commit into
JuliaDebug:masterfrom
mattlie82:fix-edit-insert-julia-1.12
Open

Fix edit_insert MethodError in debug-mode keymap fallback on Julia 1.12#421
mattlie82 wants to merge 1 commit into
JuliaDebug:masterfrom
mattlie82:fix-edit-insert-julia-1.12

Conversation

@mattlie82

Copy link
Copy Markdown

Title: Fix MethodError in debug-mode keymap fallback on Julia 1.12

Body:

Summary

Fixes #420.

On Julia 1.12, loading Debugger and then typing a character that Debugger's )-keymap intercepts (but isn't handling directly, e.g. the cursor isn't at position 0) throws:

MethodError: no method matching edit_insert(::REPL.LineEdit.PromptState, ::REPL.LineEditREPL, ::String)

Root cause

In install_repl_mode, the fallback action for the ) key defaults to the raw LineEdit.edit_insert function when nothing else is already bound to that key:

key_action = get(main_mode.keymap_dict, key, LineEdit.edit_insert)

This is later called with the keymap dispatch's calling convention, key_action(s, args...), which passes (state, repl, char) — 3 arguments. On older Julia versions, edit_insert apparently had a 3-argument method compatible with this convention, so the raw function happened to work. Julia 1.12 only defines 2-argument methods for edit_insert ((state, char)), plus an unrelated MIState catch-all, so the 3-argument call now fails.

Fix

Wrap the fallback in a small closure that matches the keymap's actual (state, repl, char) calling convention, and have it forward only (state, char) to the real edit_insert:

key_action = get(main_mode.keymap_dict, key, (s, repl, c) -> LineEdit.edit_insert(s, c))

If ) is already bound to some other action in main_mode.keymap_dict (e.g. by another package), that binding is used unchanged — this only changes the default fallback.

Testing

  • Verified on Julia 1.12.7 and 1.10.7 (aarch64-apple-darwin14): using Debugger no longer errors on load, and typing ) both enters debug> mode at an empty prompt and inserts the character normally elsewhere.
  • Ran the existing test suite locally with no new failures.
  • (Fill in here if you also tested against 1.10/1.11 via juliaup — worth doing before merge, since the fix changes behavior for all Julia versions, not just 1.12.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MethodError in edit_insert keymap fallback on Julia 1.12 (debugmode.jl:129)

1 participant