add space between lines but not wrapped lines

I am trying to make it so that when a line wraps there is less space between the different physical lines of a CodeMirror line than there is between two CodeMirror lines. Adding padding or margin to the pre tags does this but screws up CodeMirror’s measurements, so, for example, the cursor is displayed in the wrong place.

Also, more generally, what is the best way to learn about how CodeMirror does this stuff? Do I just need to dive into the source code?

1 Like

You could try adding a vertical padding to .CodeMirror pre. You’ll probably also want to set singleCursorHeightPerLine: false too to avoid cursor size issues.

Thanks. It looks like my issue was actually a bug in 5.5 that went away when I upgraded to 5.7. Thanks for the singleCursorHeightPerLine suggestion. That does improve the appearance by making the cursor height stay fixed. I had seen it on another thread, but the naming confused me – I thought I would want singleCurorHeightPerLine to be true since I want the cursor height to never change.

Of course you want the cursor height to change. When singleCursorHeightPerLine is on, the cursor is always the height of the whole (visual) line. When it is off, the cursor is the height of the character next to it.

I’m not sure if I understand understand what you are saying, but, if I don’t set singleCursorHeightPerLine: false, what happens is that when the cursor is on the last physical line of a CodeMirror line, it is very tall because it fills not only the physical line that the cursor is on but also the gap between that physical line and the next physical line (which is the first line of a new CodeMirror line). I am making this gap by setting padding-bottom on .CodeMirror pre, by the way. Luckily, I don’t need to support multiple font sizes per line (and currently I am not even trying to have more than one font size in the whole editor), so setting singleCursorHeightPerLine: false solves my use case.

1 Like