caleb-allen / VimBindings.jl

Vim bindings for the Julia REPL
https://caleb-allen.github.io/VimBindings.jl/
MIT License
111 stars 3 forks source link

REPL exit with `Error processing input` for unicode characters #65

Closed haberdashPI closed 1 year ago

haberdashPI commented 1 year ago

First of all: thanks for the work in putting this together. πŸ™ So grateful that someday I might be able to start using vim shortcuts in the julia REPL.

I got this error while using VimBindings that shut down my REPL 😒 , seems to be related to including a unicode character in the input (since I got a similar error with another greek letter).

julia> names(features, r"log.*(mean|std).*\|.*/\(Ξ΄\β”Œ Error: Error processing input
β”‚   exception =
β”‚    StringIndexError: invalid index [44], valid nearby indices [43]=>'Ξ΄', [45]=>'\\'
β”‚    Stacktrace:
β”‚      [1] string_index_err(s::String, i::Int64)
β”‚        @ Base ./strings/string.jl:12
β”‚      [2] getindex
β”‚        @ ./strings/string.jl:278 [inlined]
β”‚      [3] show(io::IOBuffer, rec::VimBindings.Changes.BufferRecord)
β”‚        @ VimBindings.Changes ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:16
β”‚      [4] show(io::IOBuffer, entry::VimBindings.Changes.Entry)
β”‚        @ VimBindings.Changes ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:194
β”‚      [5] show_full_history(selected::VimBindings.Changes.Entry)
β”‚        @ VimBindings.Changes ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:139
β”‚      [6] record(buf::IOBuffer; cursor_index::Int64)
β”‚        @ VimBindings.Changes ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:90
β”‚      [7] record
β”‚        @ ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:78 [inlined]
β”‚      [8] trigger_normal_mode(s::REPL.LineEdit.MIState)
β”‚        @ VimBindings ~/.julia/packages/VimBindings/SP6m7/src/VimBindings.jl:246
β”‚      [9] match_input(k::Dict{Char, Any}, s::REPL.LineEdit.MIState, term::REPL.Terminals.TTYTerminal, cs::Vector{Char}, keymap::Dict{Char, Any})
β”‚        @ VimBindings ~/.julia/packages/VimBindings/SP6m7/src/lineeditalt.jl:142
β”‚     [10] match_input
β”‚        @ ~/.julia/packages/VimBindings/SP6m7/src/lineeditalt.jl:118 [inlined]
β”‚     [11] match_input(k::Dict{Char, Any}, s::REPL.LineEdit.MIState, term::REPL.Terminals.TTYTerminal)
β”‚        @ VimBindings ~/.julia/packages/VimBindings/SP6m7/src/lineeditalt.jl:118
β”‚     [12] match_input(k::Dict{Char, Any}, s::REPL.LineEdit.MIState)
β”‚        @ VimBindings ~/.julia/packages/VimBindings/SP6m7/src/lineeditalt.jl:118
β”‚     [13] prompt!(term::REPL.Terminals.TTYTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
β”‚        @ VimBindings ~/.julia/packages/VimBindings/SP6m7/src/lineeditalt.jl:23
β”‚     [14] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
β”‚        @ REPL.LineEdit ~/.julia/juliaup/julia-1.9.1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:2642
β”‚     [15] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
β”‚        @ REPL ~/.julia/juliaup/julia-1.9.1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/REPL.jl:1300
β”‚     [16] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
β”‚        @ REPL ./task.jl:514
β”” @ VimBindings ~/.julia/packages/VimBindings/SP6m7/src/lineeditalt.jl:25
β”Œ Error: Error in the keymap
β”‚   exception =
β”‚    UndefVarError: `fcn` not defined
β”‚    Stacktrace:
β”‚     [1] prompt!(term::REPL.Terminals.TTYTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
β”‚       @ VimBindings ~/.julia/packages/VimBindings/SP6m7/src/lineeditalt.jl:34
β”‚     [2] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
β”‚       @ REPL.LineEdit ~/.julia/juliaup/julia-1.9.1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:2642
β”‚     [3] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
β”‚       @ REPL ~/.julia/juliaup/julia-1.9.1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/REPL.jl:1300
β”‚     [4] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
β”‚       @ REPL ./task.jl:514
β”” @ VimBindings ~/.julia/packages/VimBindings/SP6m7/src/lineeditalt.jl:36
julia> Unhandled Task ERROR: StringIndexError: invalid index [44], valid nearby indices [43]=>'Ξ΄', [45]=>'\\'
Stacktrace:
  [1] string_index_err(s::String, i::Int64)
    @ Base ./strings/string.jl:12
  [2] getindex
    @ ./strings/string.jl:278 [inlined]
  [3] show(io::IOBuffer, rec::VimBindings.Changes.BufferRecord)
    @ VimBindings.Changes ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:16
  [4] show(io::IOBuffer, entry::VimBindings.Changes.Entry)
    @ VimBindings.Changes ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:194
  [5] show_full_history(selected::VimBindings.Changes.Entry)
    @ VimBindings.Changes ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:139
  [6] record(buf::IOBuffer; cursor_index::Int64)
    @ VimBindings.Changes ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:90
  [7] record
    @ ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:78 [inlined]
  [8] prompt!(term::REPL.Terminals.TTYTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ VimBindings ~/.julia/packages/VimBindings/SP6m7/src/lineeditalt.jl:48
  [9] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/.julia/juliaup/julia-1.9.1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:2642
 [10] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/.julia/juliaup/julia-1.9.1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/REPL.jl:1300
 [11] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ./task.jl:514
ERROR: TaskFailedException
Stacktrace:
  [1] try_yieldto(undo::typeof(Base.ensure_rescheduled))
    @ Base ./task.jl:920
  [2] wait()
    @ Base ./task.jl:984
  [3] wait(c::Base.GenericCondition{ReentrantLock}; first::Bool)
    @ Base ./condition.jl:130
  [4] wait
    @ ./condition.jl:125 [inlined]
  [5] take_buffered(c::Channel{Any})
    @ Base ./channels.jl:457
  [6] take!
    @ ./channels.jl:451 [inlined]
  [7] repl_backend_loop(backend::REPL.REPLBackend, get_module::Function)
    @ REPL ~/.julia/juliaup/julia-1.9.1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/REPL.jl:244
  [8] start_repl_backend(backend::REPL.REPLBackend, consumer::Any; get_module::Function)
    @ REPL ~/.julia/juliaup/julia-1.9.1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/REPL.jl:234
  [9] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool, backend::Any)
    @ REPL ~/.julia/juliaup/julia-1.9.1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/REPL.jl:379
 [10] run_repl(repl::REPL.AbstractREPL, consumer::Any)
    @ REPL ~/.julia/juliaup/julia-1.9.1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/REPL.jl:365
 [11] (::Base.var"#1017#1019"{Bool, Bool, Bool})(REPL::Module)
    @ Base ./client.jl:421
 [12] #invokelatest#2
    @ ./essentials.jl:816 [inlined]
 [13] invokelatest
    @ ./essentials.jl:813 [inlined]
 [14] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
    @ Base ./client.jl:405
 [15] exec_options(opts::Base.JLOptions)
    @ Base ./client.jl:322
 [16] _start()
    @ Base ./client.jl:522

    nested task error: StringIndexError: invalid index [44], valid nearby indices [43]=>'Ξ΄', [45]=>'\\'
    Stacktrace:
      [1] string_index_err(s::String, i::Int64)
        @ Base ./strings/string.jl:12
      [2] getindex
        @ ./strings/string.jl:278 [inlined]
      [3] show(io::IOBuffer, rec::VimBindings.Changes.BufferRecord)
        @ VimBindings.Changes ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:16
      [4] show(io::IOBuffer, entry::VimBindings.Changes.Entry)
        @ VimBindings.Changes ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:194
      [5] show_full_history(selected::VimBindings.Changes.Entry)
        @ VimBindings.Changes ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:139
      [6] record(buf::IOBuffer; cursor_index::Int64)
        @ VimBindings.Changes ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:90
      [7] record
        @ ~/.julia/packages/VimBindings/SP6m7/src/changes.jl:78 [inlined]
      [8] prompt!(term::REPL.Terminals.TTYTerminal, prompt::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
        @ VimBindings ~/.julia/packages/VimBindings/SP6m7/src/lineeditalt.jl:48
      [9] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
        @ REPL.LineEdit ~/.julia/juliaup/julia-1.9.1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/LineEdit.jl:2642
     [10] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
        @ REPL ~/.julia/juliaup/julia-1.9.1+0.x64.linux.gnu/share/julia/stdlib/v1.9/REPL/src/REPL.jl:1300
     [11] (::REPL.var"#62#68"{REPL.LineEditREPL, REPL.REPLBackendRef})()
        @ REPL ./task.jl:514
caleb-allen commented 1 year ago

@haberdashPI thanks for the bug report! I'm sorry to hear about the crash, I hope you didn't lose too much work :frowning_face:

I think this is the same issue as #63, which was fixed in #64 but I've neglected to publish an update with the fix until now.

I've just published 0.3.5, can you update to the latest version and see if the issue persists?

haberdashPI commented 1 year ago

I think this fixed my issue. I haven't run into any problems with the new version.