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

vterm: bypass line wraps in the prompt line #717

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FrostyX
Copy link
Contributor

@FrostyX FrostyX commented Mar 30, 2023

When the command in the prompt line is so long that it wraps to multiple lines, movements such as h, l, ^, and $ IMHO behave unexpectedly. In normal terminal emulators outside of Emacs, a long prompt line contains only soft-wraps, i.e. being at the last character before a wrap and pressing <right> moves the cursor to the first character of the next line. This is also how vterm behaves without Evil. I am changing h and l to behave the same way.

While doing so, I am doing the same for ^ and $.

@FrostyX
Copy link
Contributor Author

FrostyX commented Mar 30, 2023

Just to easily illustrate behavior. When I press l without this patch, it does nothing. With this patch, it moves the cursor to the next line.

Screenshot_2023-03-30_02-37-02

Similarly h goes to the previous line

Screenshot_2023-03-30_02-37-54

This works in the visual mode as well.

@FrostyX FrostyX force-pushed the forward-backward-line-wraps branch from ffa83e7 to b3f5950 Compare March 30, 2023 11:02
@FrostyX FrostyX force-pushed the forward-backward-line-wraps branch from b3f5950 to 16c8e3d Compare April 1, 2023 22:21
"d" 'evil-collection-vterm-delete
"x" 'evil-collection-vterm-delete-backward-char))
"l" 'evil-collection-vterm-forward-char
"h" 'evil-collection-vterm-backward-char
Copy link
Collaborator

Choose a reason for hiding this comment

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

One last thing, can you add a flag (can default to true), to conditionally enable this.

Something like:

if flag:
bind l h $ ^ to -> new feature
else:
bind ^ (whatever other key needs to be deleted from thsi CL)

This cl is moving some lines to other parts so hard to tell what's missing/gained easily. (Not taking too close a look)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree, that sounds like a good idea. Please take a look.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should create 2 separate flags (one for ^ $ and one for h l) and then check the flags only in evil-collection-vterm-setup to conditionally bind the functions.

One use case I'm thinking (which is one I'd be using) is to only bind this for h & l movements but keep ^ and $ movements alone.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should create 2 separate flags (one for ^ $ and one for h l)
One use case I'm thinking (which is one I'd be using) is to only bind this for h & l movements but keep ^ and $ movements alone.

It doesn't really make sense to me, separating the configuration into two options. In my case, I either want the prompt to behave like one long line or not :-). That being said, if you are interested in having this behavior just for h, k and not ^, $, maybe others will as well. So sure, no problem with me. Do you have any preference for the option names?

check the flags only in evil-collection-vterm-setup to conditionally bind the functions.

I am trying to find some other key bind that is done this way but not seeing any. Have you seen this approach somewhere else in evil-collection? I'd like to be consistent with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

bump @jojojames

Copy link
Collaborator

Choose a reason for hiding this comment

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

(if evil-collection-elpaca-want-u-unmark

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't be as easy as we thought. Or at least as I thought.

We would have to define two variants for every movement. I am proposing hj^$ in this PR but I forgot X, 0, operations till the end of the line like C, S, D, Y, jumps like t<char>, T<char>, or line operations like yy, dd, and whatever else. That would be too many vterm specific key binds. But more importantly too many key binds for this line-continuation feature. Imagine how much would the number of key binds blow up if we want to add some other feature with conditional keybinds. There must be a smarter way of doing this but I am struggling to find it.

I am playing with overriding something like evil-line-expand but without much success. It may be a dead end as well.

You have much more experience with Evil than me, do you have any idea @jojojames, please?

When the command in the prompt line is so long that it wraps to
multiple lines, movements such as `h`, `l`, `^`, and `$` IMHO behave
unexpectedly. In normal terminal emulators outside of Emacs, a long
prompt line contains only soft-wraps, i.e. being at the last character
before a wrap and pressing `<right>` moves the cursor to the first
character of the next line. This is also how vterm behaves without
Evil. I am changing `h` and `l` to behave the same way.

While doing so, I am doing the same for `^` and `$`.
@FrostyX FrostyX force-pushed the forward-backward-line-wraps branch from 16c8e3d to 08e0259 Compare April 3, 2023 00:13
@@ -265,12 +304,10 @@ But don't allow the cursor to move bellow the last prompt line."
"P" 'vterm-yank
"a" 'evil-collection-vterm-append
"A" 'evil-collection-vterm-append-line
"d" 'evil-collection-vterm-delete
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are we removing this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved it from

  (evil-collection-define-key 'normal 'vterm-mode-map

to

  (evil-collection-define-key '(normal visual) 'vterm-mode-map

since I was creating this section, and it makes sense for d to work in visual mode as well.

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