Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codemirror - line numbers overlapped with code

I'm using codemirror latest (v5.49.0). for my electron text editor app, sometimes line numbers are rendered overlapped with the text. cannot reproduce the bug because it doesn't happen always. easily it can reproduce by refreshing the app several times. Anyone have an idea? or may be this is a known issue for you?

enter image description here

like image 464
Asaprab Avatar asked Dec 04 '22 17:12

Asaprab


2 Answers

I was having this issue as well but what worked for me was this answer from Github.

const Editor = CodeMirror.fromTextArea(element, { lineNumbers: true });
Editor.refresh();
like image 197
SeaWorld Avatar answered Jan 11 '23 09:01

SeaWorld


This answer worked for me.

import CodeMirror from 'codemirror';
import htmlembedded from 'codemirror/mode/htmlembedded/htmlembedded';
import js from 'codemirror/mode/javascript/javascript';
import 'codemirror/lib/codemirror.css';
import 'codemirror/addon/display/autorefresh';

// ...
   const codeEditor = CodeMirror.fromTextArea(this.$('#isCalculatedValueTextField')[0], {
    lineNumbers: true,
    autoRefresh:true,
    // ...

  });



like image 41
cobberboy Avatar answered Jan 11 '23 08:01

cobberboy