-
Notifications
You must be signed in to change notification settings - Fork 20
-
Notifications
You must be signed in to change notification settings - Fork 20
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
[Bug] Vim cursor sometimes (always?) disappears on Vim startup when opening a file #19
Comments
Okay I believe I found where the problem is: It is in this line of code in let &t_ti = s:GetEscapeCode(g:togglecursor_default) . &t_ti The reason is this line of code makes So instead of using concatenation like above, you can either comment it out, or not using concatenation at all, or only using concatenation if we are inside Konsole: if s:supported_terminal == 'cursorshape'
let &t_ti = s:GetEscapeCode(g:togglecursor_default) . &t_ti
endif @jszakmeister I just created a Pull Request with the above suggestion, which has worked fine for me. I am waiting for your opinion. |
Oh I forgot to mention that I am using gnome-terminal with VTE version 4002 (0.40.2) on Arch Linux which is the newest (and not yet stable) version of VTE. If you use an older version it may still work but if you upgrade to VTE 4002, the cursor disappears on Vim startup regardless of whether you're inside Tmux session or not. |
Why is gnome-terminal different here? Doesn't this have more to do with tmux than gnome-terminal? I feel like I'm missing something here--I'm pretty certain this worked with tmux and gnome-terminal previously.
Why are the first two options? How does doing this maintain tmux support?
Ah, that might explain why I see something different. Still, I'm not sure it's my bug or VTE's. |
@phongvcao Give master a whirl and see what you think. I went about fixing the issue slightly different (I didn't like depending on the shape to know whether to prefix or not). It still works where I need it.
I don't generally ride unstable builds... I don't have time to debug all the issues I run into from buggy upstream software--and I seem to have a knack for finding them. :-( I'd appreciate you giving the fix a whirl and reporting back though! |
@jszakmeister Okay great I just updated |
Great! Thanks for trying it out the new fix! |
after this fix, my cursor shape no longer changes to |
@phphong so what shape does your cursor have when you enter Vim after this fix? Can you be more specific about your platform, what version of Vim, Tmux, etc.? |
My environment:
I have tried all 3 types of cursor (underline, box, vertical bar) and in all 3 cases the cursor shape just remains the same when I enter Vim |
@phphong so when you removed the additional code from Pull Request #20 the cursor shape changed to the value you specify in let g:togglecursor_force = 'xterm'
" can be 'underline' or whatever specified in the doc
let g:togglecursor_default = 'line' My Vim on iTerm2 is working fine with this fix but I guess I will check things tonight after getting home from work. |
Yes, things works properly when I checkout commit 696ae70. I have tried your 2 lines (in my minimum |
Heh, yeah, that's right: the And just to be clear: the default cursor type is the cursor used in normal mode (not insert mode). It was to allow folks to have one setting at their normal terminal and use what makes sense within Vim. |
@phphong okay please try out my branch for
I already issued Pull Request #23 to fix this issue (my branch contains the code in the Pull Request). I am waiting for your test result. |
@phongvcao Do you have a reproduction recipe for this? How did you make the problem happen? I need some details. I built tmux 2.0 and fired Vim up under gnome-terminal on F22 (using vte 0.40.2) and could not see the problem. Guarding t_ti this way (only selectively enabling or disabling it) prevents the default cursor from being set correctly. The better answer would be for us to figure out what is tickling vte 0.40.2. It also looks like it's not tmux related? You said this earlier:
Is that correct? Is there an easy way to get an Arch Linux VM up and running? I really don't want to go through it's stupid install process. |
@jszakmeister yes it is not tmux-related. Arch Linux is a unique distro though because it is based on rolling releases. Thus, all packages are updated to their latest. The exact version of my VTE is vte3 0.40.2-1 and the But how about letting the users choose whether to set the |
@jszakmeister even if there exists a cause beside VTE (like in GNOME, GTK, etc.) I think it is too cumbersome for the plugin to detect it. Say it is some GNOME packages that conflict with VTE (like GTK3 for example) that produces this result. Then we have to check for GTK3 exact version through Vimscript? I think just having an option and let the users choose would ease future development pain. |
Meaning, if you do: let g:togglecursor_default = 'underline' in your .vimrc, Vim comes up with the normal mode cursor being an underline without any interaction from you? That's definitely not the behavior I saw. I'd definitely consider adding an option, but it'd be really nice to understand why VTE is barfing on it. I suspect that with a small change in how it's being done, it could be made to work correctly. |
@jszakmeister wait I think this time The thing is when I move my mouse pointer away gnome-terminal (or any VTE-based terminal) into another window (say Firefox), the cursor appears again. This is kinda weird. It may be a |
How do you reproduce the problem? Anything special?
|
@jszakmeister when I commented out the It is very easy to reproduct this problem on Arch Linux but maybe not on Fedora. I don't know what the cause is after your test result. |
That's not working. The whole point of t_ti is to set the normal mode cursor when you first enter vim. If it's not correct when you first enter (without going into insert mode and back), then it's broken. |
@phongvcao I've tried to reproduce this locally, but am having no luck. In my testing, I've tried using gnome-terminal to firing up vim to edit a file, and the cursor never disappears. I've done this under tmux 1.9 and 2.0 as well. At this point, I feel like I'm out of options. FWIW, Neovim has seen a bug in the VTE widget that might be somewhat related (neovim/neovim#3110). I'd recommend getting this into a reproducible state, preferably using something like the script in 3110: #!/usr/bin/env python
import sys
import time
time.sleep(2)
sys.stdout.write('\x1b[5 q')
sys.stdout.flush()
time.sleep(2)
sys.stdout.write('\x1b[2 q')
sys.stdout.flush()
time.sleep(2) One of the Neovim devs filed a ticket in the GNOME bugtracker and got a pretty quick turnaround on it. Considering the Arch Linux is a rolling distro, that might be really good for you. |
This is really to help workaround a bug seen in gnome-terminal (using VTE 0.40.2) that was causing the cursor to disappear. The user in #19 was running Arch Linux and was seeing this problem. However, I was unable to reproduce it under Fedora 22--which is also using VTE 0.40.2. As a compromise, add a way for users to avoid `t_ti` initialization and make a few notes about the issue and why this new option exists.
@phongvcao I've added a new option ( |
@jszakmeister okay great I will try a fresh re-installation of Arch Linux when I have time to test this thing out (see which package causes this, which config, etc.). Please keep this bug opened. |
@phongvcao I think this is probably the same bug you've been running into (which has been fixed in 0.41.90): GNOME/vte@c1db666 |
BTW, I was able to reproduce the problem with:
You'll see the cursor disappear for 5 seconds and then reappear with the blinking block cursor at the end. |
@jszakmeister wow you are right. When I set the You can keep the That's just my opinion. Thank you for the fix and information. Problem solved! |
Of course, we should set |
Just so I understand correctly: are you saying that you don't need the Also, I don't want to set that default for everyone. Many terminals use a non-blinking block cursor be default, so I think the current default is better. Perhaps there's something that can be done for affected versions of VTE 0.40.2 though. I'll have to think about it a bit more. |
@jszakmeister I don't need the If you don't want to make I don't think it is very easy to alter the behavior of VTE4002 because the problem lays in VTE's underlying code. We can only create some sort of small hacks though. |
So, after thinking about this more, the intent of the plugin was to make terminal vim more like gvim, which does use blinking cursors by default. So I've changed the plugin to prefer blinking versions of all cursors, and fallback as necessary for various terminals. I also changed the default of I think I'm going to leave in |
@jszakmeister sounds very good to me 👍 |
For some reasons my cursor keeps disappearing if I open a file in Vim (using
vim /path/to/file
command) inside gnome-terminal with tmux and powerline. When I change my mouse focus from gnome-terminal to another window (I am using Vim under terminal), OR replacevim-togglecursor
with this snippet of Vimscript inside my.vimrc
:Everything was working as expected. Without the above snippet of codes, sometimes even during cursor moving in Normal mode, my cursor disapearred and I had to move the mouse focus to another window beside gnome-terminal again and then move back.
I believe there is currently a problem of
autocmd VimEnter *
statement inplugin/togglecursor.vim
unable to load<SID>ToggleCursorInit()
at Vim startup, because as long as I replacedvim-togglecursor
with the above code, OR tried to move focus to another window (which triggeredFocusGained
&FocusLost
), the cursor started working again. So I guess you may want to add anautocmd BufWinEnter *
OR invoking ToggleCursorInit() outside of autocmd (so it will be run when Vim sources the.vimrc
file).Here is my version information:
OS: Arch Linux
Shell: zsh 5.0.8
Multiplexor: tmux 2.0
Vim: VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jul 11 2015 08:44:54)
Included patches: 1-778
GNOME: Version 3.16.2
The text was updated successfully, but these errors were encountered: