codemirror - line numbers overlapped with code
Asked Answered
S

3

5

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

Shortcake answered 20/11, 2019 at 10:11 Comment(1)
Having the same problem here github.com/scttcper/ngx-codemirror/issues/288Vapid
G
17

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();
Genous answered 17/2, 2020 at 15:33 Comment(1)
Autorefresh solutions didn't work for me - this did. Thanks @GenousLatishalatitude
H
4

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,
    // ...

  });



Heronry answered 17/1, 2020 at 10:28 Comment(1)
I'm using @ctrl/ngx-codemirror and unfortunately that did not work for me.Vapid
K
0

Don't know how to implement solution suggested by others.So i did this and works good for me

.CodeMirror-gutter-wrapper{
left:-29px !important;

}

Koreykorff answered 20/12, 2023 at 20:39 Comment(1)
Thank you for contributing to the Stack Overflow community. This may be a correct answer, but it’d be really useful to provide additional explanation of your code so developers can understand your reasoning. This is especially useful for new developers who aren’t as familiar with the syntax or struggling to understand the concepts. Would you kindly edit your answer to include additional details for the benefit of the community?Calpac

© 2022 - 2024 — McMap. All rights reserved.