Slow prompt display (~2s) with terminals that don't respond to cursor position queries
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 818
- Forks
- 249
- Avg merge
- 4d 14h
- Merged PRs (30d)
- 30
Description
Description
Some terminal emulators don't properly respond to CSI 6n (Device Status Report) cursor position queries, causing a ~2 second delay on every prompt display.
This was reported in nushell/nushell#17210 by a user experiencing 2-second delays when using Termius on Android to SSH into machines with nushell as the login shell.
Root Cause
In src/painting/painter.rs:174, initialize_prompt_position() calls:
let prompt_selector = select_prompt_row(suspended_state, cursor::position()?);
This cursor::position() (from crossterm) sends a CSI 6n escape sequence and waits for the terminal to respond with the cursor position. If the terminal doesn't respond, crossterm times out after ~2 seconds.
Since initialize_prompt_position() is called at the start of every read_line(), this delay happens on every prompt display, not just startup.
Affected Terminals
- Termius on Android - doesn't respond to CSI 6n queries (the reported case)
- Potentially other mobile/embedded terminal emulators
Note: Termius on Linux works fine, as does OpenSSH from Termux on the same Android device.
Suggested Solutions
-
Shorter timeout with fallback: Reduce the timeout for
cursor::position()and fall back to assuming position (0, 0) or tracking position internally when the query fails/times out -
Configuration option: Add a way to disable cursor position queries entirely for problematic terminals (e.g.,
Reedline::disable_cursor_position_query()or similar) -
Environment variable: Check for something like
REEDLINE_NO_CURSOR_QUERY=1to skip the query -
Lazy/cached querying: Only query cursor position when absolutely necessary, and cache the result
Reproduction
- Use Termius Android app to SSH into a machine with nushell as the login shell
- Observe ~2 second delay after every command before the prompt appears
The delay shows up in nushell's perf logging as:
setup reedline took 2.001272815s
References
- Original issue: nushell/nushell#17210
- Crossterm cursor position implementation uses a blocking read with timeout
- Similar issues exist in other shells/editors with terminals that don't respond to DSR queries
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/painting/painter.rs:174, where initialize_prompt_position() calls cursor::position() during read_line(), and review crossterm's blocking CSI 6n behavior. Reproduce the delay with Termius on Android or another nonresponsive terminal, then evaluate the suggested fallback, configuration, environment-variable, or caching approaches. Done means prompts no longer incur the repeated ~2-second delay while cursor positioning remains usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, performance
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100