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

vi-mode-switching reexecutes the prompt, which is slow #5783

Closed
tsoernes opened this issue Apr 1, 2019 · 17 comments
Closed

vi-mode-switching reexecutes the prompt, which is slow #5783

tsoernes opened this issue Apr 1, 2019 · 17 comments

Comments

@tsoernes
Copy link

tsoernes commented Apr 1, 2019

Setting fish_escape_delay_ms to 10 produces no change; exiting vi-mode is still very slow.

fish 2.7.1, kernel 5.0.3-200.fc29.x86_64, tried both tilix and urxvt

@faho
Copy link
Member

faho commented Apr 1, 2019

It works for me - set -g fish_escape_delay_ms 300 makes things work quite slowly.

What exactly did you execute? Did you set it in config.fish or elsewhere?

@tsoernes
Copy link
Author

tsoernes commented Apr 1, 2019 via email

@faho
Copy link
Member

faho commented Apr 1, 2019

I just reinstalled 2.7.1 (I recommend upgrading to 3.0.2 btw!), and I can't say I can reproduce this.

What does bind \e; bind -M insert \e say?

@tsoernes
Copy link
Author

tsoernes commented Apr 1, 2019

bind \e cancel
bind -M insert \e 'if commandline -P; commandline -f cancel; else; set fish_bind_mode default; commandline -f backward-char force-repaint; end'

@tsoernes
Copy link
Author

tsoernes commented Apr 1, 2019

This is the full extent of my fish config:

fish_vi_key_bindings

set -U fish_escape_delay_ms 10

function fish_prompt
    powerline-shell --shell bare $status
end

set tacklebox_path ~/.tackle ~/.tacklebox
. ~/.tacklebox/tacklebox.fish

@faho
Copy link
Member

faho commented Apr 1, 2019

Ah, okay.

Yeah, see that "force-repaint" there? That forces fish to repaint the prompt. And since it doesn't know which part will be different, it has to execute the entire thing.

Which means it'll call fish_prompt, fish_right_prompt and fish_mode_prompt. One of those must be slow for you. Make your prompt faster and the delay should disappear.

I also recommend upgrading to 3.0.2, since that's generally quite a bit faster.

@tsoernes
Copy link
Author

tsoernes commented Apr 1, 2019

So regular bash don't have to repaint the prompt? I'm using the same prompt there

@faho
Copy link
Member

faho commented Apr 1, 2019

Yes, bash does not have the assumption that the prompt can change because of vi-mode. It doesn't feature a mode indicator.

@tsoernes
Copy link
Author

tsoernes commented Apr 1, 2019

Problem solved by changing to a lighter prompt. Is there a way to get a thin and blocky cursor for insert mode and command mode respectively? That would diminish the need to have the vi mode displayed in the prompt.

@faho
Copy link
Member

faho commented Apr 1, 2019

Is there a way to get a thin and blocky cursor for insert mode and command mode respectively?

If your terminal supports it, set -g fish_cursor_default block; set -g fish_cursor_insert line.

@faho faho closed this as completed in 8ff866b Apr 1, 2019
@faho
Copy link
Member

faho commented Apr 1, 2019

Okay, I've now added a commit that makes it so this only reexecutes the fish_mode_prompt function.

That should cut the time down significantly.

@faho
Copy link
Member

faho commented Apr 1, 2019

After some careful thought, I've added 99dd6d7 which only uses fish_mode_prompt if it exists. Otherwise it acts like a normal repaint.

I'd assume there are people out there who have a mode indicator at another place in their prompt, and they seem to be okay with the time it takes. So they'd simply have to not define a fish_mode_prompt function (i.e. an empty file, not just an empty function) at all.

@faho faho changed the title fish_escape_delay_ms not respected vi-mode-switching reexecutes the prompt, which is slow Apr 1, 2019
@faho faho added this to the fish 3.1.0 milestone Apr 1, 2019
@floam
Copy link
Member

floam commented Apr 1, 2019

Huh I didn't even know about fish_cursor_default - lets feature this more prominently in the documentation and a selector in fish_config.

@faho faho added the vi-mode label Apr 1, 2019
@neon64
Copy link

neon64 commented May 7, 2019

@faho this has broken my config on the latest master - in which I have my own mode prompt inside fish_right_prompt (so it displays N, I, V etc.. on the right hand side of the screen). Is this regression intended, and if so, is there a workaround to manually re-execute fish_right_prompt every time my mode changes?

@faho
Copy link
Member

faho commented May 7, 2019

Remove fish_mode_prompt. I.e. create an empty file at ~/.config/fish/functions/fish_mode_prompt.fish

@neon64
Copy link

neon64 commented May 10, 2019

Thanks that worked! - perhaps this new behavior ought to be mentioned in the docs somewhere though

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 17, 2020
@zanchey
Copy link
Member

zanchey commented Jun 6, 2020

Updated to make even clearer in c5e535e.

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

No branches or pull requests

5 participants