codemirror / codemirror5

In-browser code editor (version 5, legacy)
http://codemirror.net/5/
MIT License
26.84k stars 4.97k forks source link

Codemirror editor is not loading content until clicked even with refresh add-on and explicitly calling refresh() #6483

Open viseth opened 3 years ago

viseth commented 3 years ago

Hi,

The "refresh" add-on works like a charm when we need to refresh only one time. Now if the textarea needs to be refresh a second time... For instance new content has been set, then the value of the codemirror instance is set but it is not shown until we click the textarea.

try this to no avail.

` var codeMirrorRef = CodeMirror.fromTextArea(document.getElementById("id_commentsHint"), { mode: "javascript", autoRefresh:true, });

codeMirrorRef.setValue(content); setTimeout(function() { codeMirrorRef.refresh(); },1); `

Please advice, Thanks,

marijnh commented 3 years ago

Is the editor hidden or otherwise unable to figure out its own on size when you call setValue? If so, you have to schedule the refresh call at the point where it becomes visible again. Toggling autorefresh off and then on again might also work.