Lines number after setText ('change' event) is broken #1356

tucnak opened this Issue Apr 6, 2013 · 3 comments


None yet
2 participants

tucnak commented Apr 6, 2013

If I call


Also, I have a handler:

editor.on('change', function() {
    var newLines = editor.session.getLength();
    if (newLines != property("lines")) { // property is a storage function
        property("lines", newLines);

Application's debug output:

[1] Lines number: 2. Text is "'use strict';
[2] Lines number: 1047. Text is "'use strict';


 * @ngdoc function


after one setText call and code listed below. So, 'change' event is called twice (no idea why) and shows 2 lines always ('use strict' + \n) before real number of lines in the document


nightwing commented Apr 6, 2013

Change event is dispatched synchronously during each part operation, setValue creates multiple change events one for removing old text and one for inserting.
Operations inserting multiple lines also will create several change events

tucnak commented Apr 6, 2013

@nightwing How can I handle visual changes, like changing the text or # of lines?


nightwing commented Apr 6, 2013

It depends on what exactly you need, but setTimeout can work see

tucnak closed this Apr 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment