Callback for editor.setValue()

314 views
Skip to first unread message

ro...@snobu.org

unread,
Jan 10, 2016, 2:15:04 PM1/10/16
to Ajax.org Cloud9 Editor (Ace)
I want to move the cursor on the last line of the editor after editor.setValue(value) has done it's thing.

Is there a callback in editor.setValue() that i can use so i know it finished loading, or should i go ahead and implement my own?
I then want to do this, which of course works but only after the editor window is populated, and for large files, it may take a few seconds:

  // only works after editor.setValue(value) has finished
  editor.gotoLine(editor.session.getLength());

Thank you.

--Adrian.

Harutyun Amirjanyan

unread,
Jan 17, 2016, 10:11:06 AM1/17/16
to ace-d...@googlegroups.com
setvalue doesn't have a callback since it is applied immediately
Do you have a demo, showing the issue?
I do not see it on https://ajaxorg.github.io/ace/kitchen-sink.html, when running following code in browser console.

editor.setValue("abcdef\n".repeat(10000)) editor.gotoLine(editor.session.getLength())



ro...@snobu.org

unread,
Jan 18, 2016, 2:34:01 PM1/18/16
to Ajax.org Cloud9 Editor (Ace)
Found out that my problem occurs a bit earlier in the execution, specifically when i'm loading the file over the network.

Something like:

        var content = ReadFileWithKnockoutJS(file);
    editor.setValue(content);

A callback on file load completion is really what i should be after.

    ReadFileWithKnockoutJS(file, ContentReadyCallback)

Thank you for trying that out.

--Adrian.
Reply all
Reply to author
Forward
0 new messages