-
Notifications
You must be signed in to change notification settings - Fork 182
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
Fixing hints when not editing at end of line #722
base: master
Are you sure you want to change the base?
Conversation
Could you please provide your |
@@ -128,7 +128,8 @@ impl<'out, 'prompt, H: Helper> State<'out, 'prompt, H> { | |||
if self.layout.cursor == cursor { | |||
return Ok(()); | |||
} | |||
if self.highlight_char() { | |||
if self.highlight_char() || self.has_hint() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why moving the cursor should invalidate the hint ?
At least, this should be configurable, not hardcoded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my example in the initial description go the pull request the cursor is moved in steps (3) to (7). In all these positions it does not make sense to insert the remaining partial part of the hint. Try to use it with the app I uploaded https://github.com/jerbs/fsidx. It has a shell mode with hints and completions implemented for long options starting with "--". I don't see in which scenario the currently implemented behaviour is useful.
E(K::Right, M::NONE) if wrt.has_hint() && wrt.is_cursor_at_end() => Cmd::CompleteHint, | ||
E(K::Right, M::ALT) if wrt.has_hint() => Cmd::CompleteHint, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer not to have this default binding in rustyline
.
See ConditionalEventHandler
to add your own custom binding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have seen that API. I can remove that commit from the pull request, if that's your preference. Just thought that it gives a better out of the box experience for everybody.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Alt+Right to get the hint completed also feels quite natural to me. With the rustyline default Alt+Right jumps to the end of the word. And that's exactly what happens when the hint is displayed right next to the cursor and Alt+Right is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #406 where Ctrl-E feels quite natural to someone else...
@@ -979,11 +979,21 @@ impl Renderer for PosixRenderer { | |||
} | |||
// display hint | |||
if let Some(hint) = hint { | |||
// position the cursor within the line |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So your PR works only on unix, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not have access to any Windows. I also don't know if Windows terminals have an insert mode? The resulting difference between Unix and Windows is that for Windows the hint is still displayed at the end of the line while it is displayed right next to the cursor on Unix. So, the difference is on presentation level only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/jerbs/fsidx for my hinter implementation. |
I will do some tests with other similar libraries but for me all of them use hint / auto-suggestion at the end of the line. |
Currently, hints are only working correctly when editing at the end of the line.
Let me describe the current behaviour using a simple example:
The line contains "abcd" and the cursor is at position zero when typing "123". That text has the hint "1234567890_".
The pipe character indicates the cursor position. The curly braces do contain the hint.
Multiple issues:
This pull request fixes all four issues.