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

Respect termios ECHO flag #673

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

IanManske
Copy link
Member

This PR makes it so that the ECHO flag given by termios is respected. That is, the input characters are not printed/echoed back to the user if the ECHO flag is missing. This will help with using rexpect to test reedline and nushell, as the syntax highlighting, etc. does not need to be accounted for.
Related to: nushell/nushell#11178

@IanManske
Copy link
Member Author

IanManske commented Nov 29, 2023

In the future, this PR might not be necessary to get rexpect working, since the latest commits introduce a way to ignore escape sequences. So, this can be used instead to get around the syntax highlighting issue once a new rexpect version comes out.

Note that for now, the PR only stops the printing of the input text -- hints, menus, or history will always be shown regardless of the ECHO flag (I think this is the most sane behavior?).

Copy link

codecov bot commented Nov 30, 2023

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (93af55c) 49.19% compared to head (56cf8e2) 49.23%.
Report is 9 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #673      +/-   ##
==========================================
+ Coverage   49.19%   49.23%   +0.04%     
==========================================
  Files          46       46              
  Lines        7930     7917      -13     
==========================================
- Hits         3901     3898       -3     
+ Misses       4029     4019      -10     
Files Coverage Δ
src/engine.rs 5.06% <6.66%> (+0.06%) ⬆️

... and 9 files with indirect coverage changes

Copy link
Member

@sholderbach sholderbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what is the best choice to test reedline's specifc behavior with rexpect or what conventions arose for other shells when given ~ECHO.
For your Nushell tests in nushell/nushell#11178 having the hinter dump stuff from the history may possibly interfere.

Cargo.toml Outdated
@@ -19,6 +19,7 @@ crossbeam = { version = "0.8.2", optional = true }
crossterm = { version = "0.27.0", features = ["serde"] }
fd-lock = "3.0.3"
itertools = "0.10.3"
nix = { version = "0.27.1", features = ["term"] }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not super critical but we could make this a unix only dependency for slightly faster downloads on windows.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, forgot to do that.

src/engine.rs Outdated
@@ -149,6 +149,9 @@ pub struct Reedline {
// Manage optional kitty protocol
kitty_protocol: KittyProtocolGuard,

// Echo typed input
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this an absolutely obscure usecase I think expanding this to a small doccomment with pointers what you are trying to achieve and the relation to the termios flag makes sense for future generations.

@IanManske
Copy link
Member Author

IanManske commented Dec 20, 2023

For your Nushell tests in nushell/nushell#11178 having the hinter dump stuff from the history may possibly interfere.

Thankfully, I don't think this will be an issue:

  • The tests so far only send whole lines, so there shouldn't? be an opportunity for the hints to show.
  • rexpect will skip over output until it finds the expected output anyways, so this should include hints. (Syntax highlighting, on the other hand, is interspersed with the output which messes things up).

This is also part of the reason why I was wondering if there was a way to disable the history for nushell or start with a blank history file.

Not sure what is the best choice to test reedline's specifc behavior with rexpect or what conventions arose for other shells when given ~ECHO.

The only example that I know off the top of my head is GNU readline. It takes into account the ECHO flag which is why rexpect doesn't have to expect lines sent to bash.

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

Successfully merging this pull request may close these issues.

2 participants