Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A part of the text is temporarily cleared while searching #533

Open
vinc17fr opened this issue Jun 25, 2024 · 5 comments
Open

A part of the text is temporarily cleared while searching #533

vinc17fr opened this issue Jun 25, 2024 · 5 comments

Comments

@vinc17fr
Copy link
Contributor

vinc17fr commented Jun 25, 2024

With some terminal sizes, a part of the text is temporarily cleared while searching.

This bug reproducible with the less 643-1 Debian/unstable package and with less 633 under Android/Termux.

To reproduce:

  1. Open a text terminal (e.g. xterm or GNOME Terminal) with 32 lines and 80 columns (under Android/Termux, I had 55 lines).
  2. Run the following command:
for i in `seq 999999`
do echo xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
done | env -u LESS less
  1. Type > to go to the end of the text.
  2. Type < to go to the beginning of the text.
  3. Type /z then [Enter] to search for "z" (something that does not appear in the text).

Result: During the search, a part of the text is cleared. For instance, with a 32-line terminal:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Note: the goal of the high number of lines in the full text is to ensure that the search takes enough time to make the issue appear. After "Pattern not found (press RETURN)" is output, the text is restored.

@vinc17fr
Copy link
Contributor Author

The bug was introduced by commit 96f2bcd for less 624.

@vinc17fr
Copy link
Contributor Author

That's the clear_eol() in 96f2bcd#diff-1c17c7f306ab222e2dfac1b6aa481d6ffe26a8a743a0f5091379da2de9668cf0R276 that triggers the issue. This is also because the cursor is somewhere in the middle of the text, and I'm wondering whether this is correct: I would expect the cursor to be on the same line as the prompt.

@avih
Copy link
Contributor

avih commented Jun 25, 2024

To reproduce: ...

For what it's worth, I can't reproduce this on windows, with a (windows) terminal size of 80 columns and either 32 lines or 55 lines.

I.e. after >, <, /z<enter> and until it displays the not-found message, the content is intact.

However, I can reproduce it on linux in xterm with size 80x32.

@gwsw
Copy link
Owner

gwsw commented Jun 26, 2024

Seems like there is a flush() missing somewhere. It needs to be called to write the buffered terminal data before a long pause, like in a search. This patch fixes it, but it may not be the best fix. I'll look into this some more.

--- a/search.c
+++ b/search.c
@@ -296,6 +296,7 @@ public void repaint_hilite(lbool on)
    }
    overlay_header();
    lower_left();
+flush();
    hide_hilite = save_hide_hilite;
 }
 #endif

gwsw added a commit that referenced this issue Jun 29, 2024
search operation. Without this, buffered data may be not
written or only partially written to the screen, so the
screen could look inconsistent while the search operation
is in progress.
Related to #533.
@gwsw
Copy link
Owner

gwsw commented Jun 29, 2024

Should be fixed in d67f5b0 in the post659 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants