dbuenzli / down

An OCaml toplevel (REPL) upgrade
http://erratique.ch/software/down
ISC License
81 stars 3 forks source link

pasting code is slow (noticable in the UI) #16

Closed hannesm closed 2 years ago

hannesm commented 5 years ago

if you take a bigger chunk of code and paste it into down, you observe lags. (compared to ocaml toplevel which does not have any lag). i suspect there's some code executed for every character that is input. i'm not entirely sure whether there is a way to get notified that more characters will be pasted, a workaround may be to delay processing of input for n ms, and reset the timer whenever new input arrives.

dbuenzli commented 5 years ago

i suspect there's some code executed for every character that is input.

Of course, that's the essence of stdin raw mode. The ocaml toplevel does not have lag because it does input buffering. But that you can't do if you want to be able to handle keyboard events.

I'm not sure there's a robust workaround around this in the limited setting we are operating. If you do feel free to give pointers to a better way. For now I'm closing this.

dbuenzli commented 5 years ago

N.B. rather than fiddle with timers I'd rather try to add adding a way to specify blocking and non-blocking mode here.

You would then gather as much as input as possible in non-blocking mode and process it. Once you no longer have anything input in blocking mode.

But then I'm never sure how reliable the non-blocking stuff is on unix (IIRC you can use O_NONBLOCK on fds and those will still block).

dbuenzli commented 2 years ago

On discuss @emillon suggested to give a try to bracketed paste mode.

dbuenzli commented 2 years ago

@hannesm if you are still using down could you please give this a try in your terminal (via opam pin down --dev) and see if that improves things on your side.

I'd like to have a few report from other terminals before actually making a release.