Search code examples
javascriptcssace-editor

How to get the total height of ACE Editor documents?


I searched the internet and found this:

editor.getSession().getDocument().getLength() * editor.renderer.lineHeight + editor.renderer.scrollBar.getWidth()

But it is assuming there's no line wraps. If I have set editor.getSession().setUseWrapMode(true); It will don't work, giving the wrong height.

How can I get the total height?


Solution

  • use session.getScreenLength() * editor.renderer.lineHeight or editor.renderer.layerConfig.maxHeight See https://github.com/ajaxorg/ace/blob/v1.2.5/lib/ace/virtual_renderer.js#L966