KristofferC / OhMyREPL.jl

Syntax highlighting and other enhancements for the Julia REPL
https://kristofferc.github.io/OhMyREPL.jl/latest/
Other
768 stars 60 forks source link

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

Closed singularitti closed 1 year ago

singularitti commented 1 year ago

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.

KristofferC commented 1 year ago

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

singularitti commented 1 year ago

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
singularitti commented 1 year ago

Hi, is it reproducible?

KristofferC commented 1 year ago

Yes

singularitti commented 1 year ago

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

KristofferC commented 1 year ago

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

PhyX-Meow commented 1 year ago

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

PhyX-Meow commented 1 year ago

https://github.com/KristofferC/OhMyREPL.jl/blob/53fa7fb304cd6b0535388162fa24e7f68cec6ddb/src/repl_pass.jl#L43 Here maybe?

KristofferC commented 1 year ago

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

singularitti commented 1 year ago

It seems to work for me. Thanks!