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
[Vim] Cursor width too small when use keycap Vim #3256
Comments
Hmm, either the CSS is messed up, or vim is trying to make the cursor 0 characters wide. I can't tell from just the picture. Do you have a reproducible example or a link to whatever you took the screenshot of? |
Of course, the page is on http://changxu.wang/test.html. |
Here's the bug: The cursor is just a space rendered over text. It renders to the same width as the text because CodeMirror uses the default monospace font in the browser. Text inside your CodeMirror instance is rendering with a non-monospace font. This is pretty obvious if you type something like The non-monospace font seems to be caused by the My suggested fix is to have a CSS rule like the below to override the monospace font to whatever you want it to be. .code-editor-codemirror .CodeMirror {
font-family: Courier;
} @marijnh do you have any thoughts on a fix we can do on our side? |
@mightyguava We could set up the vim mode to force the width of the cursor(s) to be the actual width of the character they are on top of after every selection update. It's more expensive, but should give better results. |
Thank you for your solution, it works! Thank you very much.. And, I’m agree with @marijn Haverbeke: we can set Should I submit a
|
That's not what I suggested at all. Browsers are supposed to give |
@DelightRun I believe @marijnh means to have vim mode dynamically use the actual width of the character the cursor is on top of instead of relying on the monospace font. Different browsers and OS use different fonts and we don't want to interfere with those. @marijnh how do I go about doing this? Using |
@marijinh OK, I just didn’t realize that it’s a Safari's Bug. Thanks for your help again. @yunchi Luo Is there a possible to let CodeMirror’s Vim Mode support some font’s, i.e. Chinese characters?
|
@mightyguava Exactly. But on second though this is a bit scary -- it is almost guaranteed to add another dom-layout-round-trip and the payoff doesn't seem great enough to justify that. Alternatively, we could support it in the core, but still, not sure if it's that important. |
@marijnh Yes, I agree with that. The bug appears to be isolated to Safari for CJK pages and possibly other languages. If this problems comes up again, we can add it as a @DelightRun CodeMirror should support arbitrary Unicode characters, assuming the font provides those characters as expected. Are you referring to a different issue? |
Just want to mention that the bug is reproducible in every browser. It's not about Safari only. Works much better with monospace. BUT If you want to reproduce this issue quickly just go ahead and update either:
Not sure how to fix it efficiently. As @marijnh mentioned it's not really good idea to touch DOM on every cursor-position-change. Any ideas how on we can detect a char size under the cursor? Maybe we can cheat a little bit and at least detect a char size per line... EDIT 1: |
Hello, everyone!
I use my code mirror with
keymap Vim
, and when onVim Mode
, my little green cursor's width is just 3.5px(in demo, is 9px). So I don't know what's going wrong, please help me.And here is a screen snap.
The text was updated successfully, but these errors were encountered: