KristofferC/OhMyREPL.jl

Character drifts in my REPL when using `OhMyREPL` and v1.9-rc1's IPython mode together

singularitti opened this issue ยท 10 comments

If I use OhMyREPL (after switching to JuliaSyntax) and v1.9-rc1's IPython mode together, I have the following character drifting problem:

image

In this figure, there are no characters between the end and the cursor, but the cursor looks like there is a space. Also, the end has shifted one character left. No matter whether I press tab or 4 spaces.

image

In this figure, there also looks like a space exists between et and the cursor, where there is actually none.

image

This is especially a nightmare if you have a multiline function and have parenthesis in your code; also, when deleting things, it could get wrong.

I notice that this behavior only happens when you have a multiline expression to type (or paste). While in single-line expressions, it does not happen.

julia> versioninfo()
Julia Version 1.9.0-rc1
Commit 3b2e0d8fbc1 (2023-03-07 07:51 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin21.4.0)
  CPU: 16 ร— Intel(R) Xeon(R) W-2140B CPU @ 3.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake-avx512)
  Threads: 1 on 16 virtual cores

I am reporting from an Intel mac here, but it happens both on my Intel and Apple Silicon macs, both in iTerm.app and default Terminal.app.

Interesting, I'll see if I can repro it.

My settings are:

using OhMyREPL
colorscheme!("Monokai16")
enable_autocomplete_brackets(false)

using REPL
atreplinit() do repl
    if !isdefined(repl, :interface)
        repl.interface = REPL.setup_interface(repl)
    end
    REPL.ipython_mode!(repl)
end

Hi, is it reproducible?

Yes

May I ask what might cause this? Could it be fixed?

Well I don't know what causes it. And I don't know why the IPython mode specifically would cause it either.

I notice that original prompt julia> has length 6, while in numbered mode, it is In [1]> with length 7. So I guess there is somewhere a hardcoded prompt length causing the shift. As you see in numbered mode, for 2 digit numbers, the shift will become 2 character long.
image

function untokenize_with_ANSI(io::IO, crayons::Vector{Crayon}, tokens::Vector{Token}, str, indent = 7)

Here maybe?

Nice detective work. Can it be that easy? I'll check it out.

It seems to work for me. Thanks!