GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Less initial render can open mostly blank on Windows · Issue #1883 · jline/jline3

Less initial render can open mostly blank on Windows #1883

New issue
Copy link
New issue
Copy link
Closed
#1904
Closed
Less initial render can open mostly blank on Windows#1883
#1904
Copy link

Description

@mucinoab
mucinoab
opened on May 14, 2026
Issue body actions

When using the Less class, the content is loaded and can be revealed by scrolling (up or down), but
the initial viewport is rendered incorrectly. Only part of the expected content
may be visible, and the screen can appear blank even when the source contains
many lines.

The issue appears to be in the interaction between Less,
full-screen/alternate-screen initialization, and JLine Display
cursor/clear-screen state on windows. Less enters alternate-screen mode, clears
the display, and then renders through Display; on Windows, the physical
terminal state and JLine's display model appear to diverge during that initial
render.

I have a minimal reproduction example, the code writes a block of text to the
terminal, then invokes Less on that same text. On Windows, the initial Less
display does not reliably start with the expected content at the top of the
pager.

Jline3 version: 3.30.13

package repro;

import java.io.ByteArrayInputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

import org.jline.builtins.Less;
import org.jline.builtins.Source;
import org.jline.reader.LineReader;
import org.jline.reader.LineReaderBuilder;
import org.jline.terminal.Terminal;
import org.jline.terminal.TerminalBuilder;

public final class JLineLessWindowsRepro {

    private static final String PROMPT = "> ";

    private final Terminal terminal;
    private final LineReader reader;

    private JLineLessWindowsRepro(Terminal terminal) {
        this.terminal = terminal;
        this.reader = LineReaderBuilder.builder()
                .terminal(terminal)
                .appName("jline-less-windows-repro")
                .build();
    }

    public static void main(String[] args) throws Exception {
        try (Terminal terminal = TerminalBuilder.builder()
                .name("jline-less-windows-repro")
                .system(true)
                .dumb(false)
                .build()) {
            new JLineLessWindowsRepro(terminal).run();
        }
    }

    private void run() throws Exception {
        printBanner();
        while (true) {
            if (!handle(reader.readLine(PROMPT))) {
                break;
            }
        }
    }

    private boolean handle(String rawLine) throws Exception {
        String command = rawLine == null
                ? ""
                : rawLine.trim().toLowerCase(Locale.ROOT);
        if (command.isEmpty()) {
            return true;
        }
        if ("exit".equals(command)) {
            return false;
        }
        if ("repro".equals(command)) {
            repro();
        } else {
            terminal.writer().println("Type 'repro' to reproduce, or 'exit' to exit.");
            terminal.flush();
        }
        return true;
    }

    private void printBanner() {
        terminal.writer().println("JLine Less Windows VTP repro");
        terminal.writer().println("Java: " + System.getProperty("java.version")
                + ", OS: " + System.getProperty("os.name"));
        terminal.writer().println("Terminal: " + terminal.getName() + " / "
                + terminal.getType() + " / " + terminal.getSize());
        terminal.writer().println("Type 'repro'. Type 'exit' to exit.");
        terminal.flush();
    }

    private void repro() throws Exception {
        String text = wallOfText();

        terminal.writer().print(text);
        terminal.flush();

        Less less = new Less(terminal, Path.of("."));
        ByteArrayInputStream input = new ByteArrayInputStream(
                text.getBytes(StandardCharsets.UTF_8));
        List<Source> sources = new ArrayList<>();
        sources.add(new Source.InputStreamSource(input, true, "repro.txt"));
        less.run(sources);
    }

    private String wallOfText() {
        StringBuilder builder = new StringBuilder();
        builder.append("Generated text for JLine Less\n");
        builder.append("The first visible line should be at the top of the pager.\n");
        builder.append("On affected Windows terminals, the first Less render starts\n");
        builder.append("near the row where the cursor was before Less opened.\n\n");
        for (int i = 1; i <= 180; i++) {
            builder.append(String.format(
                    Locale.ROOT,
                    "%03d  repro row for viewport-origin rendering.%n",
                    i));
        }
        return builder.toString();
    }
}

Activity

  1. mucinoab commented on May 14, 2026

    @mucinoab
    mucinoab
    on May 14, 2026
    ContributorAuthor
    More actions

    Here are my results of the reproduction.

    Windows:

    Image Image

    Mac OS:

    Image Image

    Linux:

    Image

    This is my expected result:

    Image
  2. gnodet
    closed this as completedin #1904on May 23, 2026
  3. gnodet
    added a commit that references this issue on May 23, 2026

    fix: ensure cursor position after alternate screen init (#1883) (#1904)

    a2e0670
  4. mucinoab commented on May 24, 2026

    @mucinoab
    mucinoab
    on May 24, 2026
    ContributorAuthor
    More actions

    @gnodet Thanks a lot for the quick fix.

  5. gnodet
    added a commit that references this issue on Jun 16, 2026

    fix: ensure cursor position after alternate screen init (#1883) (#1904)

    2214299
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.