Command autocomplete/history does not directly write to terminal
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
Expected behavior
When the user presses Tab after typing an incomplete command, the correct text is filled in or the text has a color applied to it.
When the user presses an up/down arrow key, previous commands are shown.
Observed/Actual behavior
When the user presses Tab after typing an incomplete command, whitespace is added after the user's provided text OR no action happens.
When the user presses an up/down arrow key, the ASCII formatting of the arrow key is added OR no action happens.
Steps/models to reproduce
On Linux or Windows: Change the calling process of Java to a terminal other than that it started with, then run Java. Read data from this terminal's stdout. Send user input to the server by writing to the server's stdin.
Plugin and Datapack List
None
Paper version
Any Paper version with command autocomplete or command history
Other
The behavior of the command autocomplete and history feature does not directly write to the correct terminal buffer, which is preventing software such as Hajime from letting users use this feature. See https://github.com/Slackadays/Hajime/issues/15
This issue manifests if the terminal file descriptor of the server is read directly with a syscall like read(). All normal text comes out just fine, and colors created by commands work perfectly, but the application of colors to typed-in text does not work.
In Hajime's case, this was originally due to the provided user input being in canonical mode which prevents the server from reading what the user is typing in until they press the Enter key. However, even after switching out of canonical mode, which now sends individual characters to the server instead, the issue persists where the server does not send ASCII color formatting (or ASCII + regular characters in the case of command history) to the file descriptor which Hajime reads and presents to the user. Debugging shows that the server isn't simply sending data that's garbled, but rather none at all. This indicated that Paper (or Java) is using a nonstandard way to modifying user input, while the correct way is to send ASCII formatting sequences.
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
Begin with the Linux or Windows reproduction: launch Java with its calling terminal changed, read the terminal's stdout, and send input through the server's stdin. Trace how Tab completion and arrow-key history update the terminal, especially with canonical mode disabled. Done means completion and history send the expected text and ASCII formatting sequences through the terminal file descriptor used by clients such as Hajime.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100