Ace Editor - go to line

I am trying to perform a fairly simple operation with Ace Editor: switching the editor to a specific line. I can't get it to work, though!

See this jsFiddle: http://jsfiddle.net/Xu9Tb/

var editor = ace.edit('editor'); editor.scrollToLine(50, true, true, function () {}); // Doesn't do anything at all editor.gotoLine(50, 10, true); // Will move the caret to the line, but it will not scroll // to the editor to the line if it off screen 

Any tips?

Thanks.

+6
source share
1 answer

An error appears in the current version of Ace Editor. If you manually editor.resize(true) , it will recalculate the height and the scroll functions will work correctly:

 var editor = ace.edit('editor'); editor.resize(true); editor.scrollToLine(50, true, true, function () {}); editor.gotoLine(50, 10, true); 

http://jsfiddle.net/Xu9Tb/1/

+10
source

Source: https://habr.com/ru/post/969551/


All Articles