Search code examples
codemirror

Codemirror line gets wider because line-number


I'm using codemirror in one project, just to provide line numbers to the text areas. The problem I'm facing that the editor gets wider while the line number grows. So if I have an editor which is 150 pixels wide, and I add 100 lines for example, it goes to 160 px wide (just example) if I reach the 1k lines it goes to 200 px wide and so on. All the lines have the same width because it is a list, but the editor still getting wider.

How can I prevent this? Thanks in advance.

EDIT At the end it was a problem with my dataset. I have accepted the only answer because it could help people with this problem on rails


Solution

  • I had a problem similar to this when I was using rails. My suggestion would be to add

    //= require codemirror
    

    to your application.js file

    and

    /*
    *= require codemirror
    */
    

    to your application.css file.

    You may not be using rails but this may help some people who come across this questions and they have this problem while trying to integrate codemirror with their rails project