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

Blinking prompt cursor after committing with lazygit and urxvt & VSCode term on Windows #2948

Open
ygaeon opened this issue Aug 20, 2023 · 13 comments
Labels
bug Something isn't working

Comments

@ygaeon
Copy link

ygaeon commented Aug 20, 2023

Describe the bug
When using lazygit, with rxvt-unicode, and exits, sometimes the cursor is blinking whilst I normally have a non-blinking cursor in the shell.

To Reproduce
I believe the following should trigger the behavior:

Start: my prompt cursor is not blinking

  1. mkdir test && cd test
  2. git init
  3. echo "Hello" > world
  4. lazygit
  5. Commit the changes with a message (I think any message will do, but here I used "test")
  6. Quit lazygit

Now, my prompt cursor is blinking.

Expected behavior
Cursor should be in the same state as when lazygit was started.

Version info:

$ lazygit --version
commit=, build date=, build source=unknown, version=unversioned, os=linux, arch=amd64, git version=2.41.0
$ equery l lazygit
 * Searching for lazygit ...
[I-O] [  ] dev-vcs/lazygit-0.40.0:0

Additional context

  • x11-terms/rxvt-unicode-9.31-r2:0
@ygaeon ygaeon added the bug Something isn't working label Aug 20, 2023
@mark2185
Copy link
Collaborator

Could you try other terminal emulators? E.g. kitty, terminator etc.?

@ygaeon
Copy link
Author

ygaeon commented Aug 20, 2023

Kitty 0.29.2
cursor_blink_interval 0 -> ~/.config/kitty/kitty.conf
Ran my test -- no blinking cursor

Alacritty 0.12.1
Ran my test -- no blinking cursor

WezTerm 20230408-112425
Ran my test -- no blinking cursor

Conclusion: urxvt does things differently :-)
(updated the original report)

@ygaeon ygaeon changed the title Blinking prompt cursor after committing with lazygit Blinking prompt cursor after committing with lazygit and urxvt Aug 20, 2023
@bartoszluka
Copy link

Also happens on Windows in VSCode terminal. When exiting it changes the configured cursor to (probably a default) blinking block, while my configured style is nonblinking vertical line.

I checked that the last version that didn't change the cursor style upon exiting is 0.29, so maybe that helps

@ygaeon
Copy link
Author

ygaeon commented Sep 28, 2023

Thank you @bartoszluka, for finding other sources of this issue. I really like my urxvt and would want to see this fixed in lazygit for sure.

@ygaeon ygaeon changed the title Blinking prompt cursor after committing with lazygit and urxvt Blinking prompt cursor after committing with lazygit and urxvt & VSCode term on Windows Sep 28, 2023
@unikitty37
Copy link

Same here on macOS in VSCode terminal. I don't even have to exit — as soon as lazygit prompts me for input (such as a commit message), the cursor is blinking.

Blinking cursors are a severe distraction for some people, so if lazygit must override the cursor, could it at least set it to a non-blinking block?

As it is, I have to juggle positioning VSCode and a separate terminal rather than simply use the built-in VSCode terminal. (Also, as a note, this doesn't occur in iTerm 2, either…)

@ygaeon
Copy link
Author

ygaeon commented Jul 12, 2024

I've noticed that if I have a blinking cursor, after using lazygit, and I just start nvim/neovim and quit, the cursor is reset to what I want.

@unikitty37
Copy link

Interestingly, lazygit resets the cursor when I quit — it just blinks while I'm using lazygit in VSCode…

@Vanav
Copy link

Vanav commented Oct 10, 2024

I confirm this issue. Seems lazygit changes cursor style for commit message dialog using XTerm control sequences (DECSCUSR). Is there any way to not change cursor style in commit dialog?

XTerm specification seems has no easy way to restore cursor style (discussion), so better to not change it.

@stefanhaller
Copy link
Collaborator

I can confirm this with VS Code's terminal on Windows (but not on Mac).

Lazygit does restore the cursor back to the default when it quits, but this whole business of ANSI escape sequences and termcap/terminfo stuff is so much of a science that I'm honestly not sure if this is a bug in VS Code's terminal. Based on a few experiments I made, I'm inclined to say that it is. For example, if you type printf "\e[5 q" then this should set your cursor to a blinking line (which works). printf "\e[0 q" is supposed to set it back to the configured default. And in Mac's Terminal.app it does; however, in VS Code it only sets the shape back to a block, but it keeps blinking. And if you try the same in various other terminal emulators, you'll see all sorts of different behaviors.

Not sure what to do about this; it takes someone with more expertise in this area than me. But in the meantime, you should be able to workaround it by doing something like alias lg='lazygit; printf "\e[2 q"'.

@ygaeon
Copy link
Author

ygaeon commented Oct 10, 2024

Thanks for that workaround @stefanhaller .. can confirm it works.

@Vanav
Copy link

Vanav commented Oct 10, 2024

@stefanhaller It works, but a bit ugly. Better to not touch cursor style at all, it is not required for lazygit functionality. For example, I use SecureCRT terminal, cursor style: wide vertical bar without blinking. But in lazygit commit text cursor style changes to blinking block for some reason. In the same time, Midnight Commander has a lot of dialog boxes and never changes cursor style.

Also, I can't restore my default cursor style "wide vertical bar", only change narrow vertical bar, seems width is missing in xterm :(

@unikitty37
Copy link

The workaround isn't useful for me, as the cursor still blinks while in lazygit. My requirements are for the cursor to not blink at any time, which is in accordance with my settings — as I said, this is an accessibility issue.

The fix is for lazygit to not mess with the cursor, or to provide a setting which disables all such messing.

@stefanhaller
Copy link
Collaborator

Ok, makes sense to me. I'd be open to changing this. (Of course it's not me who makes decisions here, it's @jesseduffield.)

Trouble is, I couldn't find any code in lazygit that does this, nor in gocui which is the TUI library that lazygit is built on. My suspicion is that this needs to be changed in tcell, but I couldn't find the code that's responsible for changing the cursor there, either.

If anybody who is more knowledgeable with this stuff than me can point me to the code that is responsible for this, I'm happy to work on a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants