Kotlin / kotlin-jupyter

Kotlin kernel for Jupyter/IPython
Apache License 2.0
1.09k stars 106 forks source link

Carriage return in output doesn't reset to line start #416

Open gabrielfeo opened 1 year ago

gabrielfeo commented 1 year ago

When a carriage return is printed to cell output,

With the Python kernel, carriage return works as expected. The use case is to print progress to cell output during a long-running operation.

Screenshot 2023-05-26 at 22 19 29 Screenshot 2023-05-26 at 22 19 22
jupyter                  1.0.0
jupyter_client           8.2.0
jupyter-console          6.6.3
jupyter_core             5.3.0
jupyter-events           0.6.3
jupyter-lsp              2.1.0
jupyter_server           2.5.0
jupyter_server_fileid    0.9.0
jupyter_server_terminals 0.4.4
jupyter_server_ydoc      0.8.0
jupyter-ydoc             0.2.4
jupyterlab               4.0.0
jupyterlab-pygments      0.2.2
jupyterlab_server        2.22.1
jupyterlab-widgets       3.0.7
kotlin-jupyter-kernel    0.11.0.385
nbconvert                7.4.0
ileasile commented 1 year ago

Looks like it's related to the logic of CapturingOutputStream. It flushes the buffer i.e. if some time limit is reached.

In this particular case, increasing output buffer size helps:

%output --max-buffer=10000000
ileasile commented 1 year ago

https://github.com/Kotlin/kotlin-jupyter/blob/master/docs/magics.md

gabrielfeo commented 1 year ago

Thanks. It does make it reset to line start, but it seems to print out of order and/or lose prints after a certain number of them:

Screenshot 2023-05-26 at 23 40 40
ileasile commented 1 year ago

So maybe max-time option should be also added %output --max-buffer=10000000 --max-time=100000

ileasile commented 1 year ago

%output --max-buffer=100000000 --max-cell-size=100000000 But I think I'll adjust the behavior of \r itself