-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Vi-mode doesn't play well with multi-line prompts #3481
Comments
What happens if you save an empty function fish_vi_cursor; end ? |
I cannot confirm this with konsole (which uses the same cursor sequences). |
Adding Here's what the envars referenced in
|
Additionally, overloading |
What are your $fish_cursor variables set to? Specifically $fish_cursor_insert and $fish_cursor_default? |
Only unknown appears to be set
|
What happens when you set them? Is there any difference between "block" and "line" and "underscore"? (Any other value should disable this function) |
Setting them makes the cursor change work, but the newline bug is still there. I've noticed a few behaviors of the newline bug:
|
That's good to know. The escape binding in insert mode is a bit complicated to allow canceling in the pager and to facilitate vi's weird behavior of moving the cursor back. Can you try |
Force repaint fixes the issue for transitioning the cursor at its current position between modes, but in testing it I found another oddity: whenever I use operations that both move the cursor and change normal to insert (eg: |
If you mean that the cursor moves back when you enter normal mode, that's on purpose, because that's what vi does.
My guess is iTerm doesn't handle that particular sequence of escape sequences correctly. Can you record a session with Can you try it with an empty |
I meant I've attached the typescript in a zip so as to prevent github from messing it up |
@paradox460, from my reading it doesn't look like this affects 2.4b1 - are you able to test that version? |
Just installed and tested 2.4b1 (via The error is still manifesting itself, and I verified that the shell was running 2.4b1 However, it does seem to be fixed in |
@paradox460: Is your cursor shape still changing with 2.3.1-712-g19e12e3? There aren't that many differences between 2.4b1 and master (i.e. 19e12e3). There are some lint fixes that should not change anything, there are some unrelated script changes that I'm confident won't change this, and there's 2a5ad19. Which is also in the Integration_2.4.0 branch (as c8fe0e5), but it should still change the cursor in your case, at least when the variables are set to something. That is unless I've misunderstood something about your configuration - are you using GNU screen or something similar? And if it still changes the cursor, I'm kinda confused as to how this should be fixed. Can you test the Integration_2.4.0 branch (which should become 2.4.0) so we can rule out the other differences? |
Sorry for the delayed response. Running Running I am not using screen or similar multiplexers. Running |
I'd imagine |
Yep, returns |
Does this still need more info? If not, and we still believe this is an unresolved issue, that label should be removed. Otherwise it should be closedd. |
Yes. Specifically, it needs someone with a bit of expertise to look at it. It requires iTerm2 (which is why I'm unable to check), and vi-mode with vi_cursor with the |
With the
The problem appears to be with this block of code in share/functions/fish_vi_cursor.fish:
If I change that
The problem is that Note that simply changing the I hate to say "I told you so" but I did in fact warn that this extremely hard to understand block of chained conditionals was likely wrong when I reviewed the change which introduced it. And that decomposing it into independent tests which are evaluated in the opposite order would be safer. That is, first test for the whitelisted scenarios that we know work despite things like |
@krader1961: I know If you can't, we can remove the tput entirely. If you can, we need to figure out why it occurs. |
Hmmm. Last night I couldn't reproduce the problem. However, I suspect that may be due to using tmux. I can reproduce the problem on a bare iTerm2 without tmux. Using Switching from normal to insert mode sends the So this is not a iTerm2 specific problem AFAICT. I'll do more testing to try and pinpoint what is causing the transition from insert to normal mode to repaint twice with the first one not properly repositioning the cursor. |
This also affects macOS Terminal.app (which uses Any output from Also, not sure what I was doing different last night but I can now reproduce this both with and without tmux between fish and the terminal. Finally, I can reproduce the problem using Running I still assert, @faho, that the block beginning with |
This patch enables fish's vi-mode cursors (e.g. a line in insert mode, a block in normal mode, an underscore in replace mode) and attempts to workaround fish-shell/fish-shell#3481. It doesn't quite work however; it only fixes the transition from insert -> normal mode. Replace -> normal, normal -> append, and probably others are still broken. It also doesn't work with `fish_mode_prompt`...
This patch enables fish's vi-mode cursors (e.g. a line in insert mode, a block in normal mode, an underscore in replace mode) and attempts to workaround fish-shell/fish-shell#3481. It doesn't quite work however; it only fixes the transition from insert -> normal mode. Replace -> normal, normal -> append, and probably others are still broken. It also doesn't work with `fish_mode_prompt`...
I was almost able to get this to work by adding Posting this here in case it gives anyone any ideas. 🤷 |
I don't think this is a problem with the cursor escape at all, I think it's a problem with printing anything from an on-variable hook invoked at prompt time. I say this because defining an I can also reproduce the Here's a fun workaround that seems to work: define But it looks like we can combine the two. Define the function to set the cursor and have it end by calling |
Oops I just found |
Hmm, after writing up code to hack Also, I hadn't tested visual mode before, and testing it now the cursor is jumping to the beginning of the line when entering/exiting visual mode. Ugh. |
What I really want is for `fish_vi_cursor` to work, but alas I still run into fish-shell/fish-shell#3481. In the meantime, the cursor still changes in vim/nvim which is most of what I would want.
Recently there are feedbacks from kitty users about the fish vi cursor issue. Continue the discussion here. @faho
sudo apt-add-repository ppa:fish-shell/release-3
sudo apt install fish
function fish_prompt; printf 'fish\n>'; end
set -g fish_key_bindings fish_vi_key_bindings
set -g fish_cursor_default block blink
set -g fish_cursor_insert line blink
set -g fish_cursor_replace_one underscore blink
set -g fish_cursor_visual block blink
Also notice that the cursor is sometimes block in insertion mode and does not change to line. You can also install the latest version of kitty, which reproduces the same issue. |
Okay, it turns out when you press them slower it reproduces more. Possibly because you're then not hitting the escape timeout? It seems the issue is some overlap between the event handler and the cursor movement. Try this: bind -M insert \e 'if commandline -P; commandline -f cancel; else; set fish_bind_mode default; commandline -f repaint-mode backward-char; end'
bind -m insert a repaint-mode forward-single-char All this does is let the bindings for "a" in normal mode and escape in insert mode repaint the mode prompt first, before doing cursor movement. This seems to avoid triggering the issue, but it's also possible it just makes the already small window even smaller. |
I tried the above configuration. It does improve a lot, but I still reproduce the issue. So, with the current event mechanism, is it possible that it could be triggered during the execution of other operations and lead to unintended results? EDIT:
I'm not familiar with the code, is there a mechanism like a queue or something to solve the same kind of issue? EDIT2: I saw in kitty's command output debug log that it's not actually a cursor down move. (1)
(2) This approach currently can solve the issue that occurs in kitty.
(3)
|
@page-down have you managed to find a satisfying workaround? |
With Fish 3.4 enabling vi cursors in Terminal.app I'm now hitting this all the time. In particular, I've noticed that pasting text from insert mode causes the prompt to move down two lines. This is presumably caused by |
The tty timestamps are changing unexpectedly, leading fish to believe that some other process has been messing with the tty and then abandoning the line. We need to figure out what's causing the tty timestamps to change. edit: it's the echoes for setting the cursor shape. |
Fixed by just re-fstating the tty after running external commands from key bindings. |
Okay, someone on macOS will want to confirm that vi cursor shaping works on iTerm with multiline prompts now and then we can remove the awkward hack that disables it. |
iTerm2 seems OK, however there's still a bug where pasting in vi mode with a multi line prompt will cause the line to move down, probably the same root cause. Reopening to fix that. |
iTerm2 looks OK to me in some medium-length testing with vi mode and multi-line prompts so I enabled it by default (#3696). |
This patch enables fish's vi-mode cursors (e.g. a line in insert mode, a block in normal mode, an underscore in replace mode) now that fish-shell/fish-shell#3481 has been fixed.
I have a multi-line prompt, where there is information displayed on one line, and the user input goes on the second. Basically handled through something like this:
This has worked without flaw in vi-mode in the past. As of version
2.3.1-667-g668de88
, and likely caused by #3215, switching modes results in the whole prompt being pushed down, not redrawn over the existing prompt.Additionally, the cursor does not redraw as a bar/underscore, but remains how its configured
System info
This issue is new, and cannot be reproduced in the stable (2.3.1) version of fish
The text was updated successfully, but these errors were encountered: