jcubic / jquery.terminal

jQuery Terminal Emulator - JavaScript library for creating web-based terminals with custom commands
https://terminal.jcubic.pl
MIT License
3.09k stars 570 forks source link

echo newline:false does not wrap text until resize #952

Closed ordo-n closed 1 week ago

ordo-n commented 1 month ago

Issue summary

When I use multiple term.echo('qwerty', {newline:false}'); it correctly doesnt add a newline, but it incorrectly doesnt process newlines until I resize the window

Expected behavior

Should not have to resize window for newline to appear

Actual behavior

Trails off to the right

Steps to reproduce

for(let i = 0; i < 100; i+=1) term.echo('qwerty', {newline:false}');

Browser and OS

All browsers

Additional notes

before resize image after resize image

jcubic commented 1 month ago

Thanks for the report, here is repro https://codepen.io/jcubic/pen/wvbmpgX

This is another problem with newline: false that was integrated with the library by a contributor. Since it was added, there were a lot of bugs that we didn't think about when merging the PR.

jcubic commented 4 weeks ago

You can fix this with a hack:

for(let i = 0; i < 100; i+=1) {
    term.echo('qwerty', { newline: false });
    term.update(-1, ...term.get_output(true).pop());
}

This will force having a clean partial render (partial is the output without newline), by refreshing the last line after each echo.

I will probably do something similar inside the library, but without creating garbage from Terminal::get_output(). If there are two partials in a row, they need to be processed as one.

jcubic commented 4 weeks ago

It seems this don't solve the problem.

jcubic commented 2 weeks ago

It's a challenging bug, it may take a while to fix. I'm not sure how to handle one edge case.

jcubic commented 1 week ago

The bug was fixed and released with version 2.42.1.